1. Create a class called myclass
2. myclass should have one private member character pointer
3. myclass should have a constructor, destructor, and 3 other public member functions
4. the constructor should allocate memory for the private pointer (size of 25) and alert the user to the fact that memory has been allocated.
5. the first member function(clearstring) should put Null values in the place pointed to by the pointer and alert the user to the fact that the string was properly initialized
6. the second member function(getstring) should prompt the user for a message to load into the string
7. The third member function (displaystring) should display the string that was loaded by the getstring() to the screen
8. the destructor should delete the allocated memory and alert the user to the fact that memory has been released.
9. in the main function instantiate the class as an object and make sure you call all the member functions.
these are the criteria for this first assignment of the quarter, and this is what I have so far.
header
//Header for Unit01 Lab
#include <iostream>
using namespace std;
MyClass::~MyClass
{
private:
int *pointer;
}
source file
#include "MyClass.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;
class MyClass
{
pointer = new int[25];
cout << "Memory has been allocated for the pointer";
}
void clearString()
{
memset(pointer, '/0', sizeof(pointer);
cout << "The string has been properly initialized";
}
void getString()
{
cout << "Please leave a message";
cin >> *pointer;
}
void displayString()
{
coud << *pointer;
}
int main()
{
return EXIT_SUCCESS;
}
I have 1 error that I'm trying to work out on my own
Quote
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.
my only other question is how do I get the display to show in the display string member function, and to delete it?
thanks,
Cp
This post has been edited by circuspeanuts: 12 June 2009 - 12:05 PM

New Topic/Question
Reply




MultiQuote




|