2014-02-26 34 views
0

您好我是新來的Visual Studio 2010 當我嘗試建立我的代碼,它告訴我:C++錯誤C2065:「值」:未聲明的標識符-Newbe

count.cpp(18): error C2065: 'Value' : undeclared identifier

那是我count.cpp碼發放錯誤:

#include "StdAfx.h" 
#include "count.h" 


count::count(void): Value(0), ResetValue(0){} //constructor 

count::~count(void){} //destructor 

int GetValue(){return Value;} //Accessor to get value by another class 

這裏是我的count.h代碼:

#pragma once 
class count 
{ 
public: 
    count(void); 
    virtual ~count(void); 
    int GetValue(); 
private: 
    int Value; 
    int ResetValue; 
}; 

這是將是使用計數對象d由一個countWindow對象。 所以我想要一個「GetValue」訪問器,並使用countWindow對話窗口中的指針。

當我實際使用構造函數時,變量值是否在行12上未聲明和啓動? 還是不鏈接到count.h文件中的聲明?

因爲如果我創建另一個void函數來做一個Value ++,Visual Studio看起來很好用。

謝謝你的時間!

回答

0

GetValue被聲明爲全局而不是count類的成員。前言本聲明的GetValue與數::

int count::GetValue(){return Value;} //Accessor to get value by another class 
0
int count::GetValue(){return Value;} //Accessor to get value by another class 

注數:

相關問題