gpt4 book ai didi

c++ - 为什么所有cout和cin的“未声明标识符

转载 作者:行者123 更新时间:2023-12-01 15:06:10 25 4
gpt4 key购买 nike

在我的main.cpp中,所有cout和cin都有错误。

/**
* Description: This program demonstrates a very basic String class. It creates
* a few String objects and sends messages to (i.e., calls methods on)
* those objects.
*
*/
//#include <iostream>
#include "mystring.h"
//using namespace std;

/* Function Prototypes */

void Display(const String &str1, const String &str2, const String &str3);


/*************************** Main Program **************************/

int main()
{
String str1, str2, str3; // Some string objects.
char s[100]; // Used for input.

// Print out their initial values...

cout << "Initial values:" << endl;
Display(str1, str2, str3);

我的main.cpp无法更改,所以我的问题是,如何解决此错误,我必须在头文件和实现文件中添加什么?

最佳答案

In my main.cpp all of my cout's and cin's have errors.



您只需要 include <iostream>头文件,并使用 stdcoutcin:
#include <iostream>
//^^
int main()
{
std::cout << "Initial values: "<< std::endl;
//^^
}

关于c++ - 为什么所有cout和cin的“未声明标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17499381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com