c++ expression syntax error

来源:百度知道 编辑:UC知道 时间:2024/06/06 19:10:05
#include <iostream>
using namespace std;

#include "data.h"

int main(){
Data student();
student.readfile( "assign-5-data.txt" );

student.SelectionSort(student.getName(),student.getNumberOfStudent());
//print the data
student.printfile();

char a;
cout<<"Do you want to search for a name?(y/n)";
cin>>a;
cout<<endl;
if(!(a=='y' || a=='Y')) return 0;
cout<<"type the name please:";

const int Max = 51;
char* theName;
char buffer[Max];
//read the name to the buffer first
cin >> buffer;
//create an integer to save the length of the name
int nameLength;
//to find out the length
for(nameLength=0; buffer[nameLength]!='\0';nameLength++);
//create the porinter array the ri

Data student();
你这是在申明一个函数而不是定义一个对象

在VC6,空构造定义对象,好像不能加括号

int main(){
Data student();
改为
int main(){
Data student;

Data student();

改为

Data student = new Data();

前者是声明一个方法,该方法返回一个Data类型的引用
后者才是声明引用并创建实例