挂羊头卖犬肉
挂羊头卖犬肉
挂羊头卖狗肉的人
关注数: 104
粉丝数: 398
发帖数: 4,246
关注贴吧数: 63
数组下标类型size_t primer99页说数组下标类型的正确行使是size_t,可是我在VC上使用size_t的时候它没有变蓝,请问这个类型是C++自己定义的,还是C语言理也有size_t类型呢?
char *p问题 #include <iostream> using namespace std; int main() {char *p; cin>>p; cout<<p<<endl; } 这段代码到底能不能运行? 我用VC2008可以通过编译,但执行生成的文件时候会报错
亮瞎我的X眼,这段代码竟然也可以运行 #include <iostream>//示范主函数 using namespace std; int get(); const int x=get(); int main() { cout<<x<<endl; return 0; } int get() {int x; cin>>x; return x; } 不是说const 定义的只读变量在编译的时候必须给出初始值吗?这怎么可以运行中再读出初始值呢?
嵌套 #ifndef #define #endif结构有什么作用呢? 刚看了一下cmath的内容,发现了大量的#ifndef #define #endif嵌套定义的, 这个是有什么作用呢? 一段代码用一个#ifndef #define #endif 结构让其不重复编译不久足够了吗?干嘛还要这么多的嵌套呢。 另下面代码也是我在里面看到的, inline long __CRTDECL abs(_In_ long _X) {return (labs(_X)); } inline double __CRTDECL abs(_In_ double _X) {return (fabs(_X)); 这里的In_ long _X中的In_ long 是什么数据类型呢? 我在文档里搜索了一下,也没有找到typedef ,求大牛指点
int i;cout<<i<<endl; ANSI标准中初始化问题 如题,ANSI标准对未初始化的变量默认值有规定吗?如 int i; cout<<i<<endl; 输出神马呢?还是每个编译器一个样子?
谭浩强的C++程序设计看完了,在吧里是什么水平? RT,习题也全部都做了一遍。
紧急伸手 #include <cmath> #include <iostream> #include <string> #include <iomanip> #include <fstream> using namespace std; main() {ifstream infile1("f6.txt",ios::in); ofstream outfile2("f7.txt",ios::app); //创建outfile1和outfile2 if(!(infile1&&outfile2)) {cerr<<"created error"<<endl; exit(1); } int x,i; while(!infile1.eof()) {infile1>>x; outfile2<<x<<" "; }
【天天向上】奶茶粉丝过来冒个泡 RT,有在北京的朋友想一起去清华看奶茶的吗?留言
求问输出流 cout究竟是ostream的对象还是ostream_assign的对象呢? 如果是ostream_assign的对象,那自己定义的类定义 << 重载的时候都把返回值类型设为 ostream型呢?
又伸手了 标题要长长长长长长长长长 一个工作空间编译链接的时候.h的头文件会被编译吗? 还是它只是在被#include 的时候插入到源程序代码中,它自身不用编译的。 如一个类的声明头文件。
伸手党现身 标题要长长长长长长长长长 求问#include <iostream.h> 和用#include <iostream> using namespace std的区别
测试下本版哪些字不能发 一个帖子总是发布出来,现在测试下 1、默认
紧急伸手 class string //声明类string { public: string(char *q=NULL); void display(); friend string operator = (string &p1,string &p2); //声明 = 运算符 ---报错行--- friend bool operator > (string &p1,string &p2); //声明 > 运算符 friend bool operator < (string &p1,string &p2); //声明 < 运算符 friend bool operator == (string &p1,string &p2); //声明 ==运算符 private: char *p; }; string::string(char *q) //定义构造函数 {p=q; } string operator = (string &p1,string &p2) //定义 = 运算符 ---报错行--- {p1.p=p2.p; return(p2); }
小白问题求助 3 我用的VC6.0,在运行复数类的时候出了问题如下: #include <iostream.h> 去掉 using namespace std; 定义复数类complex 定义 + 重载函数,complex+complex 这段代码测试了,可以运行 定义转换构造函数 complex(float) 代码测试了,可以运行 然后主函数中complex x(1,2),y; y=x+2 运行 报错 改成y=x+complex(2),可以运行,结果也正确。 谭的书上说直接y=x+2就可以,我的为什么不行呢?求解释
小白问题紧急求助->SOS complex operator / (complex &x,complex &y) //定义 / 运算符重载函数 { if(y.real==0&&y.imag==0) -----{cout<<"input error"<<endl; -----这里我想结束这个函数,不执行函数体下面的语句,用什么好呢,return语句行吗? -----} return complex( (1/(y.real*y.real+y.imag*y.imag))*(x.real*y.real+x.imag*y.imag),(1/(y.real*y.real+y.imag*y.imag))*(x.imag*y.real-x.real*y.imag)); } 麻烦各位好心的高手了!
令人毛骨悚然的图片
小白问题求助 SOS #include <iostream> #include <iomanip> #include <cmath> #include <string> using namespace std; class complex { public: complex(float x=0,float y=0); void display(); complex complex_add(complex &c); private: float real; float imag; }; complex::complex(float x,float y) {real=x; imag=y; } complex complex::complex_add(complex &c) {return(complex(c.real+real,c.imag+imag)); //这里为什么可以使 用C的私有数据成员呢? } void complex::display() {cout<<real<<"+"<<imag<<"i"<<endl; } main() //主函数 {complex x(3,4),y(5,-10),z; z=x.complex_add(y); z.display(); }
首页
1
2
3
4
下一页