马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这段代码一直显示报错。求大佬指点
报错内容如下:
kidult@FreedydeMacBook-Pro MyCpp % cd "/Users/kidult/Desktop/MyCpp/" &
& g++ public&protected&prviate.cpp -o public&protected&prviate && "/Us
ers/kidult/Desktop/MyCpp/"public&protected&prviate
[1] 53912
[2] 53913
[3] 53914
[4] 53915
zsh: command not found: protected
[2] exit 127 protected
zsh: command not found: prviate
zsh: command not found: prviate.cpp
[2] 53917
zsh: command not found: protected
[3] exit 127 prviate.cpp -o public
[4] - exit 127 protected
zsh: command not found: prviate
zsh: command not found: protected
[2] + exit 127 protected
kidult@FreedydeMacBook-Pro MyCpp % clang: error: no such file or directory: 'public'
clang: error: no input files
[1] + exit 1 g++ public
kidult@FreedydeMacBook-Pro MyCpp %
#include<iostream>
#include<string>
using namespace std;
class Person{
public:
//设置姓名
void setName(string name){
m_Name = name;
}
//获取姓名
string getName(){
return m_Name;
}
//获取年龄
//设置情人
private:
//姓名 可读可写
string m_Name;
//年龄 只读
int m_Age;
//情人 只写
string m_Lover;
};
int main(){
Person p;
p.setName("孙桐");
cout << "姓名:" << p.getName() << endl;
system("pause");
return 0;
}
文件名的问题,代码好像没问题,去掉文件名中的&,或者用_代替试试
|