易截截图软件、单文件、免安装、纯绿色、仅160KB

c/c++类成员函数的传参问题!详细问题求高手解答。。

#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
void get_value()
{cin>>num>>name>>sex;}
void display()
{
cout < <"num:" < <num < <endl;
cout < <"name:" < <name < <endl;
cout < <"sex:" < <sex < <endl;
}
private:
int num;
string name;
char sex;
};
class Student1:public Student
{
public:
void display_1(int &age,string &addr)
{
cout < <" age:" < <age < <endl;
cout < <"address:" < <addr < <endl;
}
int age;
string addr;
};
int main()
{
Student1 stud;
stud.get_value();
stud.display();
stud.display_1(10,"haha");
return 0;
}

用VS2005编译 报这个错误Student1::display_1”: 不能将参数 1 从“int”转换为“int &”
请问 如果我非要stud.display_1(10,"haha");
void display_1(int &age,string &addr)
要怎么写?
你要把引用去掉,写成display_1(int, string );

引用
你要把引用去掉,写成display_1(int, string );

编译通过了 但是值感觉还是没传过去啊

4 str m


相关问答:

C 程序问题 (二) - C/C++ / C语言

问一下:
#include <stdio.h>
int main()
{
  char x, y, z;
  int i;
  int a[16];
  for(i=0; i<=16; i++)
  {
  a[i] = 0;
  ......

能用C/C++简单实现五子棋程序吗?

最近突然想自己来实现一个五子棋程序,但不知道怎么开始,自己也没学画图形函数,能在控制台下直接写吗>>>?????
控制台?比图形界面更麻烦。
http://search.download.csdn.net/search/%E4%BA%94%E5%AD%90% ......

使用C的高手请进

大家好!我是一位C爱好者,向大家请教下,C程序员可好找工作?公司用C干些什么?
无所谓好不好找工作,一般通信、系统、嵌入式、硬件方面用的多,而且由于C的底层特性,学会后在学其他的会比较容易

不管用什么语 ......

c中的转义字符问题

    '\108'作为字符常量对不对?
转义字符'\ddd'表示3位8进制所代表的字符。 但是108不是正确的8进制表示方法,因此应该是错误的。
但是char a='\108'; 为什么编译不出错呢?
\108 没超过 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号