Artist wrote:
<snip>
See my comments below.
class riaaconner {
Nice naming. ;)
Public:
Should be lowercase.
public:
conname = cnget;
cartist = caget;
This doesn't work. You can't assign an array. I will suggest a better
solution below.
char cngsend[30]
char cagsend[30]
int dgsend
You forgot your semi-colons here.
endl;
This statement doesn't do anything. If you want to print a newline you
have to pass it to cout:
cout << endl;
Or just use << endl << endl at the end of each output line.
<snip>
There are several other problems with your code. First of all, you
shouldn't use character arrays to store strings. There are many good
reasons. Among them:
a) You have no control over the user input. If someone enters more than
30 characters your program will probably crash.
b) You have to manually keep track of and copy the characters.
c) It doesn't do what you expect when you compare or assign.
Instead, you should use the 'string' class. It works exactly as
expected, like all the other built-in types and accepts an arbitrary
number of input characters. Here's an example:
#include <string>
using namespace std;
// ...
string mystring;
mystring = "hello!";
cout << mystring;
Second of all, your class is fairly useless. It just serves as a big
bag to put stuff in instead of representing a true logical object.
There are a few things you can do to make it better. First, let your
class read itself instead of doing it outside:
public:
void Read()
{
cin >name;
cin >artist;
}
You would use this class like so:
MyClass obj;
obj.Read();
For writing you do the same thing. Have a member function that does it:
public:
void Write()
{
cout << name;
cout << artist;
}
Once you get it to work with 'cin' and 'cout' you can make it work with
any stream. You just have to pass your streams as parameters, like so:
void Read(istream& input);
void Write(ostream& output);
Now, to call the Read and Write functions you have to pass it an open
stream (possibly a file), like so:
obj.Read(inputfile);
obj.Write(outputfile);
Try all the things I mention and then post your code again.
Regards,
Bart.