Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 类和OOP帮助C++;_C++_Oop - Fatal编程技术网

C++ 类和OOP帮助C++;

C++ 类和OOP帮助C++;,c++,oop,C++,Oop,我在为类编写一个简单的代码时遇到了麻烦,我试图找出如何将用户输入添加到类中,我尝试了多种方法,确实需要一些帮助 迄今为止的代码: #include <iostream> #include <string> using namespace std; // Base class class GameShow{ public: string Name; cout << "Enter name of constest

我在为类编写一个简单的代码时遇到了麻烦,我试图找出如何将用户输入添加到类中,我尝试了多种方法,确实需要一些帮助

迄今为止的代码:

#include <iostream>
#include <string>
using namespace std;

// Base class
class GameShow{
    public:
        string Name;
        cout << "Enter name of constestant: ";
        cin >> Name;
        cout << "Welcome " << Name <<"! Let's get ready to play the FEUD!!" << endl;
};


// Derived class
class FamilyFued{
    public:
    points;

};


int main ()
{
    GameShow TN;
    TN.Name
    return 0;
}
#包括
#包括
使用名称空间std;
//基类
课堂游戏表演{
公众:
字符串名;
姓名;

cout类用于抽象事物的状态和行为。 状态以类属性的形式存在。 行为以类方法(函数)的形式出现

这是一种行为:

cout << "Enter name of constestant: ";
cin >> Name;
cout << "Welcome " << Name <<"! Let's get ready to play the FEUD!!" << endl;
cout>Name;

CUT

基于你所拥有的,你可能想要包装<代码> cOUT>……;CIN < P>你缺少太多的基础知识,你需要从一本好的C++书籍开始。 ;

//是个坏主意,在堆栈溢出中被提到了数千次。

坏的

})

假设您想打印
GameShow
类成员的
Name
,那么请将行更改为下面的行

std::cout << TN.Name;

std::cout Stackoverflow不是免费的教学服务。你需要通过阅读一些C++的基本书籍来学习C++编程。首先,找出并解释需要解决的问题。你不能只是复制和粘贴你的代码只是寻求帮助。
class GameShow{
public:
    string Name;
    GameShow()
    {
        cout << "Enter name of constestant: ";
        cin >> Name;
        cout << "Welcome " << Name <<"! Let's get ready to play the FEUD!!" << endl;
    }
};
class GameShow{
    public:
        string Name;
        cout << "Enter name of constestant: ";
        cin >> Name;
        cout << "Welcome " << Name <<"! Let's get ready to play the FEUD!!" << endl;
};
class GameShow{
public:
    string Name;
    GameShow()
    {
        std::cout << "Enter name of constestant: ";
        std::cin >> Name;
        std::cout << "Welcome " 
                  << Name 
                  << "! Let's get ready to play the FEUD!!" << std::endl;
    }
TN.Name // what this line doing in your main function ??
std::cout << TN.Name;