Object error

This is a discussion on Object error within the C++ Programming forums, part of the General Programming Boards category; I'm using g++ as the compiler and I'm trying to make a dog object and have it "bark". I get ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    3

    Object error

    I'm using g++ as the compiler and I'm trying to make a dog object and have it "bark".
    I get this error: explicit qualification in declaration of 'void Bark()'
    Here's the code:

    Code:
    #include <iostream>
    class Dog
    {
    	public:
    	 void Bark();
    };
    
    void::Bark()
    {
    	std::cout << "Bark!\n";
    }
    
    int main()
    {
    	Dog Shasta;
    	system("CLS");
    	std::cout << "Here is a dog! It's name is Shasta! Listen to it bark!\n\n";
    	Shasta.Bark();
    	std::cout << " ";
    	Shasta.Bark();
    	
    	return 0;
    }
    How can I fix the problem?
    Last edited by artitatt; 04-21-2008 at 09:17 PM.

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by artitatt View Post
    Code:
    void::Bark()
    {
    	std::cout << "Bark!\n";
    }
    Where is class "void" defined?

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    3
    actually i think i see my error.
    void isn't defined. i should have written void Dog::Bark()
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21