所以我在名为Classes.h的头文件中有以下代码:
#ifndef CLASSESS_H
#define CLASSESS_H
class PalindromeCheck
{
private:
string strToCheck;
string copy;
public:
PalindromeCheck(string testSubject) : strToCheck(testSubject) {} //Constructor
void Check()
{
copy = strToCheck; //Copy strToCheck into copy so that once strToCheck has been reversed, it has something to be checked against.
reverse(strToCheck.begin(), strToCheck.end()); //Reverse the string so that it can be checked to see if it is a palindrome.
if (strToCheck == copy)
{
cout << "The string is a palindrome" << endl;
return;
}
else
{ …Run Code Online (Sandbox Code Playgroud) 这是假设,但我有一个带有两个重载构造函数的类 - 其中没有一个是默认的构造函数.如果我从另一个调用一个构造函数,它会递归吗?例:
class Example
{
Example(const int integer)
{
//Constructor Code Here
}
Example(argument)
{
Example object(68);
//Rest of constructor code
}
};
Run Code Online (Sandbox Code Playgroud)