谁能告诉我如何将对象传递给C++函数?
还有比我更好的解决方案?
#include<iostream>
using namespace std;
class abc
{
int a;
public:
void input(int a1)
{
a=a1;
}
int display()
{
return(a);
}
};
void show(abc S)
{
cout<<S.display();
}
int main()
{
abc a;
a.input(10);
show(a);
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud) 这是学生报告卡项目,当我将此代码从borland C转移到开发C++时,我遇到了一些问题.现在,当我尝试在开发C++中编译程序时,它给出了gotoxy()的错误消息没有定义.那么我需要包含哪个头文件才能使用gotoxy()函数?
//***************************************************************
// HEADER FILE USED IN PROJECT
//****************************************************************
#include<iostream>
#include<graphics>
#include<fstream>
#include<iomanip>
using namespace std;
//***************************************************************
// CLASS USED IN PROJECT
//****************************************************************
class student
{
int rollno;
char name[50];
int p_marks,c_marks,m_marks,e_marks,cs_marks;
float per;
char grade;
int std;
void calculate()
{
per=(p_marks+c_marks+m_marks+e_marks+cs_marks)/5.0;
if(per>=60)
grade='A';
else if(per>=50 && per<60)
grade='B';
else if(per>=33 && per<50)
grade='C';
else
grade='F';
}
public:
void getdata()
{
cout<<"\nEnter The roll number of student ";
cin>>rollno;
cout<<"\n\nEnter The Name of student ";
gets(name);
cout<<"\nEnter The marks …Run Code Online (Sandbox Code Playgroud) c++ ×2