C++笔记(2)小问题

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();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值