所以我正在阅读 C++primer 6th edition 并且正在学习结构,但是在尝试运行测试文件时出现以下错误:
xubuntu@xubuntu:~/C/C$ make test
g++ test.cpp -o test
test.cpp: In function ‘int main()’:
test.cpp:14:41: error: expected primary-expression before ‘.’ token
make: *** [test] Error 1
xubuntu@xubuntu:~/C/C$
编码:
#include <iostream>
#include <stdio.h>
struct test{
char name[20];
float age;
float worth;
};
int main(){
using namespace std;
test chris = {"Chris", 22, 22};
cout << "This is Chris's data:" << test.chris;
return 0;
}