1.该错误只看第一行
2.g++ -c .cc//只编译没错误
g++ xx.o//collect:ld return 1 exit main()函数的字母拼写错误,找不到主函数所以无法链接!
3.
#include <iostream>
using namespace std;
int main()
{
int score;
cout << "input score:";
cin >> score;
if(score > 100)
cout << "over 100!" << endl;
else if(score == 100)
cout << "A" << endl;
else if(score>=90)
cout << "B" << endl;
else if(score>=80)
cout << "C" << endl;
else if(score>=70)
cout << "D" << endl;
else if(score>=60)
cout << "E" << endl;
else if(score>=0)
cout << "F" << endl;
else
cout << "Less than 0" << endl;
return 0;
}
4.\r:回车符 return 回到本行最左边
\n:换行符
5.c++中的金科玉律:先声明后使用
6.用你会用的知识做你想做的事情(在改错的时候,用认识的单词去推测出错的含义)
.undeclared 未声明
reported 报告
7.c++编译器对生命变量的处理是给他规划一块内存空间,执行的时候真正分配内存空间
类型决定空间大小 跟数据大小没有关系
默认:整数是int类型
小数是double类型
const 定义的常量必须初始化
const 类型 名字=初始值
类型 const 名字=初始值
8.相关代码:
#include <iostream>
using namespace std;
int main()
{
cout << "abcd\rxy" << endl;
int n;
cout << "n=" << n << endl;
n=100;
cout << "n=" << n << endl;
n=200;
cout << "n=" << n << endl;
cout << endl;
cout << sizeof(char) << endl;
cout << sizeof(int) << endl;
cout << sizeof(float) << endl;
cout << sizeof(double) << endl;
return 0;
}