S
sandy
I think I just need a pair of eyes here... I can't see what I am doing
wrong.
I am creating a new Class for an assignment, Class File.
I have a header and a cpp file. When I try to write the constructor in
the cpp file it tells me:
File.cpp new types may not be defined in a return type
File.cpp return type specification for constructor invalid
I don't see a return type for/from my constructor so I figure it must
be confused and I have done something else wrong. Below are the header
and .cpp.
Thanks.
< HEADER CODE>
#ifndef File_h
#define File_h
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
class File
{
private:
string Name, Extension;
public:
/*
Constructor
Inputs: FullName
Outputs: None
Notes: Takes in the full name (name + extension) splits it.
*/
File(string FullName);
/*
GetName
Inputs: None
Outputs Name (minus extension)
*/
string GetName();
/*
GetExtension
Inputs: None
Outputs: File Extension
*/
string GetExtension();
/*
Print
Inputs: None
Outputs: prints to screen full file name (name and extension)
*/
void Print();
/*
operator ==
Inputs: File F
Outputs: bool
Notes: If the file.Name and file.Extension are equal the files
are equal if either is not equal, the files are not equal.
*/
bool operator==(const File & F);
/*
operator <
Inputs: File F
Outputs: bool
Notes: If the full file name is < the 'other' file name True.
*/
bool operator<(const File & F);
/*
operator >
Inputs: File F
Outputs: bool
*/
bool operator>(const File & F);
}
#endif
</HEADER CODE>
<CPP CODE>
#include "File.h"
#include <iostream>
#include <cstdlib>
#include <string>
//using namespace std;
/*
Constructor
*/
File::File(string FullName)
{
int charLoc; // character location
}
</CPP CODE>
wrong.
I am creating a new Class for an assignment, Class File.
I have a header and a cpp file. When I try to write the constructor in
the cpp file it tells me:
File.cpp new types may not be defined in a return type
File.cpp return type specification for constructor invalid
I don't see a return type for/from my constructor so I figure it must
be confused and I have done something else wrong. Below are the header
and .cpp.
Thanks.
< HEADER CODE>
#ifndef File_h
#define File_h
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
class File
{
private:
string Name, Extension;
public:
/*
Constructor
Inputs: FullName
Outputs: None
Notes: Takes in the full name (name + extension) splits it.
*/
File(string FullName);
/*
GetName
Inputs: None
Outputs Name (minus extension)
*/
string GetName();
/*
GetExtension
Inputs: None
Outputs: File Extension
*/
string GetExtension();
/*
Inputs: None
Outputs: prints to screen full file name (name and extension)
*/
void Print();
/*
operator ==
Inputs: File F
Outputs: bool
Notes: If the file.Name and file.Extension are equal the files
are equal if either is not equal, the files are not equal.
*/
bool operator==(const File & F);
/*
operator <
Inputs: File F
Outputs: bool
Notes: If the full file name is < the 'other' file name True.
*/
bool operator<(const File & F);
/*
operator >
Inputs: File F
Outputs: bool
*/
bool operator>(const File & F);
}
#endif
</HEADER CODE>
<CPP CODE>
#include "File.h"
#include <iostream>
#include <cstdlib>
#include <string>
//using namespace std;
/*
Constructor
*/
File::File(string FullName)
{
int charLoc; // character location
}
</CPP CODE>