-3
このプログラムをコンパイルすると、エラーが発生します。無効と宣言した。ヘッダーファイルとcppファイルの2つのファイルがあります。このエラーの原因は不明です。変数または変数 'var of field'が宣言されたvoid
/////thinker.h
#include <cstring>
#include <assert.h>
#include <string>
class thinking_cap
{
public:
void slots(char new_green[], char new_red[]);
void push_green() const;
void push_red() const;
private:
char green_string[50];
char red_string[50];
};
//////// thinker.cpp
#include <iostream>
#include <stdlib.h>
#include "thinker.h"
int main()
{
thinking_cap student;
thinking_cap fan;
student.slots("Hello", "Goodbye");
fan.slots("Go Cougars!", "Boo!");
student.push_green();
fan.push_green();
student.push_red();
return 0;
}
void thinking_cap::slots(char new_green[ ], char new_red[ ])
{
assert(strlen(new_green) < 50);
assert(strlen(new_red) < 50);
strcpy(green_string, new_green);
strcpy(red_string, new_red);
}
void thinking_cap::push_green
{
cout << green_string << endl;
}
void thinking_cap::push_red
{
cout << red_string << endl;
}
:エラーが終了し、自分の言葉を再開ところ、少なくともそれは明らかではない。これを試してみてください – EJP