Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. C++ Problem

C++ Problem

Scheduled Pinned Locked Moved The Lounge
c++helpquestion
10 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alois Kraus
    wrote on last edited by
    #1

    Is it possible to call a specialized function of a base class ? I mean: class A { protected: virtual int f() { return -1; }; void DoFunc() { printf("\nValue: %d",f()); }; }; class B : public A { protected: virtual int f() { return 1; }; }; int main() { B Inst; Inst.DoFunc(); } Is it possible to get the class A to print 1 ?

    C A J R 4 Replies Last reply
    0
    • A Alois Kraus

      Is it possible to call a specialized function of a base class ? I mean: class A { protected: virtual int f() { return -1; }; void DoFunc() { printf("\nValue: %d",f()); }; }; class B : public A { protected: virtual int f() { return 1; }; }; int main() { B Inst; Inst.DoFunc(); } Is it possible to get the class A to print 1 ?

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      Alois Kraus wrote: Is it possible to get the class A to print 1 ? not in a forum where programming questions aren't allowed, no. -c


      If Ben Affleck is sexy, then the terrorists have won. --Sheerly Avni

      Smaller Animals Software

      1 Reply Last reply
      0
      • A Alois Kraus

        Is it possible to call a specialized function of a base class ? I mean: class A { protected: virtual int f() { return -1; }; void DoFunc() { printf("\nValue: %d",f()); }; }; class B : public A { protected: virtual int f() { return 1; }; }; int main() { B Inst; Inst.DoFunc(); } Is it possible to get the class A to print 1 ?

        A Offline
        A Offline
        Alvaro Mendez
        wrote on last edited by
        #3

        Please post this question in the Visual C++ forum and make sure you at least make your member functions publically accessible. :rolleyes: Regards, Alvaro


        Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)

        A 1 Reply Last reply
        0
        • A Alvaro Mendez

          Please post this question in the Visual C++ forum and make sure you at least make your member functions publically accessible. :rolleyes: Regards, Alvaro


          Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)

          A Offline
          A Offline
          Alois Kraus
          wrote on last edited by
          #4

          Did already do that. But I bet You wont be able to solve the problem ;P;P;P

          T A 2 Replies Last reply
          0
          • A Alois Kraus

            Did already do that. But I bet You wont be able to solve the problem ;P;P;P

            T Offline
            T Offline
            Tim Smith
            wrote on last edited by
            #5

            He already did and sent me the answer. We just aren't going to share. Tim Smith I'm going to patent thought. I have yet to see any prior art.

            A 1 Reply Last reply
            0
            • T Tim Smith

              He already did and sent me the answer. We just aren't going to share. Tim Smith I'm going to patent thought. I have yet to see any prior art.

              A Offline
              A Offline
              Alvaro Mendez
              wrote on last edited by
              #6

              :muahahahahaha: (where's that evil laugh emoticon when we need it?) :-) Regards, Alvaro


              Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)

              T 1 Reply Last reply
              0
              • A Alois Kraus

                Did already do that. But I bet You wont be able to solve the problem ;P;P;P

                A Offline
                A Offline
                Alvaro Mendez
                wrote on last edited by
                #7

                Well, even if I can't, it'll still be your problem won't it? ;P;P;P Regards, Alvaro


                Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)

                1 Reply Last reply
                0
                • A Alois Kraus

                  Is it possible to call a specialized function of a base class ? I mean: class A { protected: virtual int f() { return -1; }; void DoFunc() { printf("\nValue: %d",f()); }; }; class B : public A { protected: virtual int f() { return 1; }; }; int main() { B Inst; Inst.DoFunc(); } Is it possible to get the class A to print 1 ?

                  J Offline
                  J Offline
                  Jorgen Sigvardsson
                  wrote on last edited by
                  #8

                  The way I see it, one or more of the following applies:

                  • Your compiler is broken, thus you have to ask us.
                  • You haven't figured out how your compiler works.
                  • You get a kick out of asking a programming question in a non-programming forum.
                  • You have been struggling with this problem for weeks, and you finally solved it. So to show the world how great you are at C++, you hope to make us newbies pull our hair in agony trying to solve the problem.

                  If I would have had the ability to smooth talk like John Simmons, this post would have been less sarcastic and more to the point. -- standing so tall, the ground behind no trespassers, on every floor a garden swing, and another door she makes it clear, that everything is hers A place of abode, not far from here, Ms. Van de Veer

                  1 Reply Last reply
                  0
                  • A Alvaro Mendez

                    :muahahahahaha: (where's that evil laugh emoticon when we need it?) :-) Regards, Alvaro


                    Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)

                    T Offline
                    T Offline
                    Tomas Petricek
                    wrote on last edited by
                    #9

                    :666::cool:

                    1 Reply Last reply
                    0
                    • A Alois Kraus

                      Is it possible to call a specialized function of a base class ? I mean: class A { protected: virtual int f() { return -1; }; void DoFunc() { printf("\nValue: %d",f()); }; }; class B : public A { protected: virtual int f() { return 1; }; }; int main() { B Inst; Inst.DoFunc(); } Is it possible to get the class A to print 1 ?

                      R Offline
                      R Offline
                      retZ
                      wrote on last edited by
                      #10

                      You should have a new public (not private or protected) member function in class B, inside which you would call A's DoFunc() function... There are no failures; there are only extended learning opportunities.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups