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. General Programming
  3. C / C++ / MFC
  4. classes and the namespace operator ::

classes and the namespace operator ::

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 3 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.
  • K Offline
    K Offline
    kitty5
    wrote on last edited by
    #1

    okey dokey. I have 2 classes: class imageViewer{...}; class camData{...}; imageViewer has a function called funcA(); camData has a function called funcB(); I wanted to call funcA; in funcB(); i.e.:i've tried both: #include "imageViewer.h" void camData::funcB() { .. imageViewer::funcA(); } I get this error: error C2352: 'ImageViewer::showPicture' : illegal call of non-static member function -AND- #include "imageViewer.h" void camData::funcB() { .. funcA(); } I get this error: error C3861: 'showPicture': identifier not found could someone please tell me my idiotic mistake..... thanks, Kitty

    Kitty5

    C P 2 Replies Last reply
    0
    • K kitty5

      okey dokey. I have 2 classes: class imageViewer{...}; class camData{...}; imageViewer has a function called funcA(); camData has a function called funcB(); I wanted to call funcA; in funcB(); i.e.:i've tried both: #include "imageViewer.h" void camData::funcB() { .. imageViewer::funcA(); } I get this error: error C2352: 'ImageViewer::showPicture' : illegal call of non-static member function -AND- #include "imageViewer.h" void camData::funcB() { .. funcA(); } I get this error: error C3861: 'showPicture': identifier not found could someone please tell me my idiotic mistake..... thanks, Kitty

      Kitty5

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Well, in order to call a function (non-static) from a class, you first need to have an instance of your class. So, doing something like that (suppose MyClass is a class that defines funcA): MyClass A; A.funcA(); You cannot simply do MyClass::funcA();


      Cédric Moonen Software developer
      Charting control [v1.1]

      K 1 Reply Last reply
      0
      • C Cedric Moonen

        Well, in order to call a function (non-static) from a class, you first need to have an instance of your class. So, doing something like that (suppose MyClass is a class that defines funcA): MyClass A; A.funcA(); You cannot simply do MyClass::funcA();


        Cédric Moonen Software developer
        Charting control [v1.1]

        K Offline
        K Offline
        kitty5
        wrote on last edited by
        #3

        :Cedric, thanks very much for your advice. I knew it was something simple that I was missing... thanks! Kitty :-D

        Kitty5

        1 Reply Last reply
        0
        • K kitty5

          okey dokey. I have 2 classes: class imageViewer{...}; class camData{...}; imageViewer has a function called funcA(); camData has a function called funcB(); I wanted to call funcA; in funcB(); i.e.:i've tried both: #include "imageViewer.h" void camData::funcB() { .. imageViewer::funcA(); } I get this error: error C2352: 'ImageViewer::showPicture' : illegal call of non-static member function -AND- #include "imageViewer.h" void camData::funcB() { .. funcA(); } I get this error: error C3861: 'showPicture': identifier not found could someone please tell me my idiotic mistake..... thanks, Kitty

          Kitty5

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          kitty5 wrote:

          .. imageViewer::funcA();

          To make such call possible. finA() must be static function of class imageViewer.

          Prasad Notifier using ATL | Operator new[],delete[][^]

          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