我搜索了Google和这个网站以找到答案.我也在课本中阅读过,但我仍然不明白它是如何应用的.
这就是我所知道的:
它用于显示对象对自身的了解.
它可以用于格式化输出关于它自己知道的内容.
它必须在要使用的方法中被覆盖.
我想删除使用命名空间std,但我不知道所有需要加前缀.
#include <iostream>
#include "PlayingCard.h"
using namespace std;
PlayingCard makeValidCard(int value, int suit);
int main()
{
// Create a playing card
PlayingCard card1;
// Test the default constructor and GetCardCode
cout << "Testing default constructor. Expect card code to be 00\n card code is :";
cout << card1.getCardCode() << endl << endl;
// Test the setter and getter
cout << "Seting card to 'AH' using SetValue and SetSuit" << endl;
card1.setCard('A', 'H');
cout << "GetValue returns :" << card1.getValue() << …Run Code Online (Sandbox Code Playgroud) 我正在阅读的C++书告诉我们,数组将使用常量变量设置,但我想让用户输入指示数组的大小,并且它有效.是否有我应该担心的问题.
尝试在code :: blocks中编译以下代码时,我遇到了这个单独的错误.
错误发生了8行.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos = (40, 3);
SetConsoleCursorPosition(screen, pos);
cout << "O" << endl;
Sleep(500);
for (int tossIt = 1; tossIt <= 3; tossIt++)
{
while (pos.Y <= 20)
{
SetConsoleCursorPosition(screen, pos);
cout << "|" << endl;
pos.Y++;
SetConsoleCursorPosition(screen, pos);
cout << "O" << endl;
Sleep(100);
}
while (pos.Y > 3)
{
SetConsoleCursorPosition(screen, pos);
cout << " " << endl;
pos.Y--;
SetConsoleCursorPosition(screen, pos);
cout …Run Code Online (Sandbox Code Playgroud)