0
我是C++的新手,並試圖弄清楚一些事情。之一的,我面對並不能確定問題是出從主()方法調用函數時,我接收範圍誤差的:C++:在main方法中運行函數
[email protected] /cygdrive/c/Documents and Settings/---/folder
$ g++ test.cpp
test.cpp: In function ‘int main()’:
test.cpp:90:9: error: ‘test01’ was not declared in this scope
test01();
用於TEST.CPP的代碼如下。
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class stringStuff {
vector<string>* elements;
int frontItem;
int rearSpace;
int upperBound;
public:
stringStuff(int capacity) {
vector<string>* elements = new vector<string>(2*capacity);
frontItem = capacity;
rearSpace = capacity;
upperBound = 2 * capacity;
}
virtual void test01(){
stringStuff* sd = new stringStuff(100);
// test code here
}
};
/** Driver
*/
int main() {
test01();
}
我在這裏做錯了什麼?
關於術語的注意事項:'main'不是方法AKA的成員函數。 – hyde