error C2871: 'std' : does not exist or is not a namespace
解答:#include <iostream.h>
把它改成#include <iostream>就可以了.
#include <iostream.h>
与
#include <iostream>
using namespace std;
是等效的..
error C2556: 'void __thiscall......overloaded function differs only by return type from 'int __thiscall
头文件部分:
#ifndef TESTCounter_H
#define TESTCounter_H
class counter{
int value;
public:
counter(int number);
void increment(void); //给原值加1
void decrement(void); //给原值减1
int getvalue(); //取得计数器的值
void print(void); //显示计数器的值
};
#endif
源文件部分:
#include <iostream>
#include <string>
#include "testCounter.h"
using namespace std;
counter::counter(int number){
}
void counter::increment(){
}
void counter::decrement(){
}
counter::getvalue(){
return 0;
}
void counter::print(){
}
error LNK2001: unresolved external symbol "private: static int Circle::count
头文件部分:
#ifndef TESTCIRCLE_H
#define TESTCIRCLE_H
class Circle
{ public:
Circle(float r)
{ radius=r;
++count;
}
~Circle() { --count; }
static int num() { return count; } //静态成员函数
private:
float radius;
static int count; //静态数据成员
};
int Circle::count=0;
#endif
源文件部分:
Circle c1(1);
Circle c2(2);
Circle c3(3);
cout<<c1.num();