I'm writing a C++ program in 3 separate files. Here's some of the pseudocode:
Rectangle.h
_________
...
private *char name;
rectangle
deconstructor
getName
setName
draw
Rectangle.cpp
_________
default constructor: name = "bleh";
constructor: [asks the user to enter a name and prints it back]
draw: [print name]
getName: gets the name
setName: modifies the name
deconstructor: deletes the string
TestRectangle.cpp
___________
...
Rectangle r1;
r1.draw();
r1.getName();
How do I... er... do all of this? I have to allocate memory for the string using the new keyword.
I've been trying to look this stuff up but can't seem to find anything helpful.
C++ Pointers to Strings?
"Algorithms + Data Structures = Programs", by Wirth.
You evidently learned C++ before you learned programming. Take a break and learn programming now.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment