SFML community forums

Help => General => Topic started by: CreaM on April 05, 2014, 02:43:14 pm

Title: cycled class
Post by: CreaM on April 05, 2014, 02:43:14 pm
class dog{
        public:
                bool tellname1()const;
                 void givename(bool);
                void tellname2();
        private:
                bool name;
        };

        bool dog::tellname1()const{return name;}
        void dog::givename(bool prom) {name= prom;}
        void dog::tellname2() {int a = dog.tellname1();std::cout << a;}
 
Hi, how can i make this class working - class which is using one of its own privates variables?
Title: Re: cycled class
Post by: Nexus on April 05, 2014, 02:44:52 pm
tellname1()const;
That's not a valid function declaration.

Apart from that, most classes use their own private variables, it's nothing special.

But you should really learn C++ with a good book (http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list), these are absolute basics that you have to understand before using SFML...
Title: Re: cycled class
Post by: CreaM on April 05, 2014, 03:50:10 pm
ok, the problem actualy was:
void dog::tellname2() {int a = dog::tellname1();std::cout << a;}
 
btw better than buy book is to ask here :P, still thanks
Title: Re: cycled class
Post by: Santa-Claus on April 05, 2014, 04:05:53 pm
You better first learn the basics from a book then ask every little question....
Title: Re: cycled class
Post by: Nexus on April 05, 2014, 04:34:15 pm
btw better than buy book is to ask here :P
Not really. We can't (and won't) solve every basic C++ problem, especially since this is a SFML forum and not a C++ forum. You have to show individual initiative, and that includes at least coming up with a minimal complete example, as stated by the forum rules (http://en.sfml-dev.org/forums/index.php?topic=5559.0).

If you want to learn C++ seriously, you must read a good book, there's no way around it. Of course you can learn it halfway through internet tutorials, but you don't do yourself a favor, you'll only waste a lot of time with unnecessary trouble. Furthermore, you could look for a forum that is focused on C++ programming rather than the SFML library.