我想包括班级,但这没有工作
我刚刚学习C++。我正在关注 YouTube 视频,但我陷入了这个阶段。下面是我的文件。
// main.cpp
#include <iostream>
#include "Person.h"
int main()
{
Person foo;
foo.set_age(25);
std::cout << foo.get_age() << std::endl;
return 0;
}
// Person.h
#ifndef PERSON_H
#define PERSON_H
#pragma once
class Person
{
public:
void set_age(int a);
int get_age();
private:
int age;
};
#endif
// Person.cpp
#include "Person.h"
void Person::set_age(int a)
{
age = a;
}
int Person::get_age()
{
return age;
}
我刚刚在vscode中搭建了开发环境并安装了code runner。
每当我单击此处的“运行”按钮时
,它都会显示
启动:程序'.....main.exe'不存在
是否有像php Composer
这样的工具可以自动管理它?
将 .cpp 文件的内容移至 .h 文件。
效果很好。但我想把这两个文件分开管理。
I'm just learning C++. I'm following a YouTube video, but I'm stuck at this stage. Below is my files.
// main.cpp
#include <iostream>
#include "Person.h"
int main()
{
Person foo;
foo.set_age(25);
std::cout << foo.get_age() << std::endl;
return 0;
}
// Person.h
#ifndef PERSON_H
#define PERSON_H
#pragma once
class Person
{
public:
void set_age(int a);
int get_age();
private:
int age;
};
#endif
// Person.cpp
#include "Person.h"
void Person::set_age(int a)
{
age = a;
}
int Person::get_age()
{
return age;
}
I just set up the development environment in vscode and installed code runner.
Whenever I click the Run button here
It says
launch: program '.....main.exe' does not exist
Is there a tool like php composer
that automatically manages it?
Moved the contents of the .cpp file to the .h file.
It worked fine. But I would like to separate the two files for management.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论