Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: cycled class  (Read 3112 times)

0 Members and 2 Guests are viewing this topic.

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
cycled class
« 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?
« Last Edit: April 05, 2014, 02:54:31 pm by . »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: cycled class
« Reply #1 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, these are absolute basics that you have to understand before using SFML...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: cycled class
« Reply #2 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

Santa-Claus

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: cycled class
« Reply #3 on: April 05, 2014, 04:05:53 pm »
You better first learn the basics from a book then ask every little question....

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: cycled class
« Reply #4 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.

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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything