For class we are required to implement a signature block on all our assignments. To do this I've created a Signature Block class, but I'm having trouble implementing it. When I try to compile in Dev C++ I get this error:
[Error] request for member 'toString' in 'myblock', which is of non-class type 'SignatureBlock()'
#include <iostream>
#include <string>
#include "SignatureBlock.h"
// Assignment 1: Requests user's name and says "Hello."
usingnamespace std;
int main(int argc, char** argv) {
string name; // string to store user's name
SignatureBlock myblock(); // create a signature block object
cout << myblock.toString(); // send signature to standard output
cout << "What is your name? "; // prompt for name
getline(cin, name); // store user's name in name variable
cout << "Hello, " << name << "!" << endl; // output greeting
return 0;
}
#include <string>
// Implementation file for SignatureBlock.h class. To be used in all assignments
// Default Constructor
SignatureBlock::SignatureBlock()
{
// Assign values to class variables
name.assign("Leroy Jenkins\n");
courseID.assign("CIS215\n");
email.assign("leroyjenkins@gmail.com\n");
}
// toString function to return string representation of the SignatureBlcok
std::string SignatureBlock::toString()
{
std::string retval;
retval.append(name);
retval.append(courseID);
retval.append(email);
return(retval);
}
SignatureBlock.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <string>
// Header file for class SignatureBlock. To be used in all assignments (CIS 215)
class SignatureBlock
{
// protected strings to store parts of signature
protected:
std::string name;
std::string courseID;
std::string email;
// public functions to access or mutate protected variables
public:
SignatureBlock(); // Default Constructor
std::string toString(); // Accessor
// In future: could add additional constructors, acessors, and/or mutators
}
;
Thanks for the suggestion, but unfortunately just fixing that did not correct the errors. So, obviously there's a whole lot more wrong with the code. Any other suggestions are certainly welcome.