The idea of the exercise is to create a frame window when outputting the users name.
In the book the exercise takes place in the main cpp file, but I like to get into a OO mindset when making programs so I tried to change this exercise accordingly.
The errors I get say:
Error 1 error C2653: 'NonLoopGreeting' : is not a class or namespace name
Warning 2 warning C4305: 'argument' : truncation from 'int' to 'char'
Warning 3 warning C4309: 'argument' : truncation of constant value
IntelliSense: name followed by '::' must be a class or namespace name
Below is the code.
NonLoop_fGreeting.h
#ifndef NONLOOP_FGREETING_H
#define NONLOOP_FGREETING_H
class NonLoopGreeting
{
public:
void nlGreeting();
};
#endif
NonLoop_fGreeting.cpp
#include <string>
#include <iostream>
using namespace std;
void NonLoopGreeting::nlGreeting()
{
cout << "Please enter your first name: " << endl;
string name;
cin >> name;
// Build message that I intend to write.
const string greeting = "Hello, " + name + "!";
// Builds 2nd and 4th line of the framed window.
const string spaces(greeting.size(), ' ');
const string second = "* " + spaces + " *";
// Builds 1st and 5th line of the framed window.
const string first(second.size(), ' *');
cout << endl;
cout << first << endl;
cout << second << endl;
cout << "* " << greeting << " *" << endl;
cout << second << endl;
cout << first << endl;
}
Main.cpp
#include "NonLoop_fGreeting.h"
int main()
{
NonLoopGreeting nonLoop;
nonLoop.nlGreeting();
return 0;
}
The errors mostly point to line 5 of the NonLoop_fGreeting.cpp file.
Any help is greatly appreciated.
This post has been edited by CasGrimes: 06 August 2010 - 09:22 AM

New Topic/Question
Reply




MultiQuote





|