Thread: Classes Project (Not class project)

  1. #1
    Registered User
    Join Date
    Feb 2011

    Classes Project (Not class project)

    Hey guys, this is my first full program involving classes, so I'm not sure if I'm way off.

    #include <iostream>
    using namespace std;
    class Dog
    	char dogName[20];
    	void Dog::speak(char dogName);
    class Cat
    	char catName[20];
    	void Cat::speak(char catName);
    char animal[5];
    void Dog::speak(char dogName)
    	cout<<"\nPlease enter the name of the dog in question: ";
    	cout<<"The dog "<<dogName<<" says bark bark"<<endl;
    void Cat::speak(char catName)
    	cout<<"\nPlease enter the name of the cat in question: ";
    	cout<<"The cat "<<catName<<" says meow."<<endl;
    void main
    	cout<<"Would you like to know about a cat or a dog?"<<;
    		animal == "cat" || "Cat" || "CAT";
    It keeps saying that my 'main' looks like a function definition... am i missing something?

  2. #2
    Registered User
    Join Date
    Oct 2006
    look at the way your main function is declared, and compare it to the way your other functions are declared (hint: the others are correct).

  3. #3
    Registered User
    Join Date
    Feb 2011
    void main()??

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    No, int main().
    Change all char to std::wstring (don't forget to include <string>).
    Change cout to wcout, and cin to wcin.
    Move animal into main.
    Correct your if statement which is incorrect (it's if (a == b || a == c || a == d)).
    You have to create instances of your animals (cat, dog) if you want to use them. The classes are merely blueprints describing the animals.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Classes, pointer to itself to access from a child class
    By lautarox in forum C++ Programming
    Replies: 7
    Last Post: 09-23-2010, 12:43 PM
  2. Input class project (again)
    By Elysia in forum C++ Programming
    Replies: 41
    Last Post: 02-13-2009, 10:52 AM
  3. organizing classes in a game
    By MathFan in forum Game Programming
    Replies: 2
    Last Post: 04-28-2005, 09:23 AM
  4. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM