Thank you all for your prompt replies. As I do not see an individual reply option, I shall reply to each of you in this message.
To Handy Andy: Your reply was quite helpful. I did, however, make a couple of small changes to your code. The functional thing that I changed was I got rid of the cout. the goal of my project was to print the names of the objects. Your code produced the same effect in the console, but it wasn't the way in which I wanted the result. Also, thank you for the suggestion about the variable name. I took it. The problem I had with the for loop was that I thought that
charAlphabet == 'z'
would make the loop run until charAlphabet was equal to 'z'.
To JLBorges: Thank you for your reply. You obviously took a fair bit of time on this response and for that I thank you. I am a beginner and have some questions regarding some of the things you said/used. I read the section of the article on not explicitly calling new and delete: what is this leak the article talks of? Would my to functions:
1 2 3 4 5 6 7 8
|
Animal* allocateMemoryForAnimalArray(){
Animal* animal = new Animal[26];
return animal;
};
void deallocateMemoryForAnimalArray(char* memoryToBeDeallocated){
delete [] memoryToBeDeallocated;};
|
fix this problem? Also, at one point, before I posted to this forum, I tried replacing lines 29 and 42 with these functions, but it didn't work. The main function wouldn't recognize animal when I did this. Why is that?
Thank you for the resources.
To helios: Thank you for your reply. I see your point. I am a beginner and am just doing this for a challenge. However, I do want to improve at coding and learn more. That being said, JLBorges' reply is still useful to me, espicially since he included resources to help me figure out what he did.
To againtry: Thank your for your reply also. I like your for loop that uses i to run the loop twenty-six times and name the objects. Your code is concise. When I put your code in my compiler it gave me a message saying that m_name was not initialized in the constructor. It does not count this message as a warning and the code works. Why is it displaying this message?
Thank you all for your assistance, BroBuilder.