VS为我提供了对构造函数的另一个解决方案,但我想知道为什么我的工作不起作用
VS is giving me another solution to my constructor but I want to know why mine wont work
我的构造函数下面有一个绿线,说"未找到功能定义"。
Visual Studio为我提供了解决方案,但我想知道为什么我的工作不起作用。
#pragma once
#include "class_dayType.h"
#include <iostream>
#include <string>
using namespace std;
int main() {
dayType day;
string d;
cout << "Enter day of week: ";
cin >> d;
day.set_day(d);
}
#include <iostream>
#include<string>
using namespace std;
class dayType {
public:
string day;
dayType(); //constructor with green line
void set_day(string day_of_week) {
string day = day_of_week;
}
};
Visual Studio在另一个文件中创建了此功能,并且起作用。这与我的构造函数有什么区别?
dayType::dayType()
{
}
错误:
lnk2019未解决的外部符号" public:__thiscall daytype :: daytype(void("(?? 0dayType @@ qae@qae@xz(在函数中引用_main day_of_week
lnk1120 1未解决的外部day_of_week
dayType();
这不是定义,而只是声明。它表明构造函数(或任何函数(将在代码中的某个地方存在。
。您需要
dayType()
{
}
在这里和这里阅读更多。
相关文章:
- 运行同一解决方案的另一个项目的项目
- Project Euler问题4的错误解决方案
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 我想知道长双倍和双倍之间的区别
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- visual c++,如何获取解决方案目录中的代码
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- C++Matching Brackets 2解决方案不起作用
- 在 ubuntu3 上C++ goto 定义有什么解决方案吗16.04?
- 我是 C++ 的初学者,我想知道如何在 2D 矢量中获取重复值
- 在 leetcode 上提交解决方案时出现堆栈缓冲区溢出错误
- 我想使用 "cout" 命令慢慢打印文本,但我真的找不到任何解决方案
- VS为我提供了对构造函数的另一个解决方案,但我想知道为什么我的工作不起作用
- 我想知道这个原因和解决方案
- 这段代码处于无限循环中,想知道如何解决它
- (欧拉计划#3)试图将Python中的解决方案复制到C++,结果非常糟糕,不知道如何
- 具有进程间通信功能的服务器-客户端日志记录体系结构.你知道解决方案吗?
- 如何想出这样的解决方案?(检查数独是否有效)
- 几个模板问题(已经解决了…只是想知道为什么)
- VS2015可执行文件成为病毒(有潜在的解决方案,但不知道为什么)