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. Use inline member function to refer different levels of classes. [modified]

Use inline member function to refer different levels of classes. [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++visual-studioagentic-ai
15 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.
  • D Don Box

    CMsgRecorder::SetGroupState

    seems has not been defined. Check its defination or show us the class declaration and the defination of the above function.

    Come online at:- jubinc@skype

    C Offline
    C Offline
    CodingLover
    wrote on last edited by
    #3

    Inline member function as follows.

    public:
    CMsgRecorder& GetMsgRecorder(void);

    Class definition as follows.

    class CMsgRecorder
    {
    public:
    void SetGroupState(char chState)
    };

    I appreciate your help all the time... Eranga :)

    C 1 Reply Last reply
    0
    • C CodingLover

      Inline member function as follows.

      public:
      CMsgRecorder& GetMsgRecorder(void);

      Class definition as follows.

      class CMsgRecorder
      {
      public:
      void SetGroupState(char chState)
      };

      I appreciate your help all the time... Eranga :)

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

      Yeah but were is the SetGroupState function defined ? There is just a declaration there. You need to provied a body for the function otherwise you'll get a linker error. And BTW, you cannot double click on linker errors. Also, modify your first post in order to remove the pre tags: if such longs strings we can only see a part of your message.

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

      C 1 Reply Last reply
      0
      • C Cedric Moonen

        Yeah but were is the SetGroupState function defined ? There is just a declaration there. You need to provied a body for the function otherwise you'll get a linker error. And BTW, you cannot double click on linker errors. Also, modify your first post in order to remove the pre tags: if such longs strings we can only see a part of your message.

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

        C Offline
        C Offline
        CodingLover
        wrote on last edited by
        #5

        Ok here the body of SetGroupState()

        void CMsgRecorder::SetGroupState(char chState)
        {
        string strName = m_DiskFile.GetFileName();
        }

        I used this as

        m_pCtlAgent->GetMsgRecorder().SetGroupState('R');

        where "m_pCtlAgent" is the control agent.

        I appreciate your help all the time... Eranga :)

        C 1 Reply Last reply
        0
        • C CodingLover

          Ok here the body of SetGroupState()

          void CMsgRecorder::SetGroupState(char chState)
          {
          string strName = m_DiskFile.GetFileName();
          }

          I used this as

          m_pCtlAgent->GetMsgRecorder().SetGroupState('R');

          where "m_pCtlAgent" is the control agent.

          I appreciate your help all the time... Eranga :)

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

          I see. But why do you speak about inline functions ? Where is that inline coming form ? Did you forget something in your code ?

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

          C 1 Reply Last reply
          0
          • C Cedric Moonen

            I see. But why do you speak about inline functions ? Where is that inline coming form ? Did you forget something in your code ?

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

            C Offline
            C Offline
            CodingLover
            wrote on last edited by
            #7

            Why I use it, because that inline function(as I told earlier) is defined in another class. Inking to there is fine, just include header files. I guaranteed that it is work fine. So basically this involve with three classes. I'll explain it much as follows,

            CMsgRecorder& GetMsgRecorder(void);

            defined in CFocusGroup.h

            m_pCtlAgent->GetMsgRecorder().SetGroupState('R');

            defined in CCmdLine.cpp

            SetGroupState()

            used in CMsgRecorder.cpp and CMsgRecorder.h

            I appreciate your help all the time... Eranga :)

            C 1 Reply Last reply
            0
            • C CodingLover

              Why I use it, because that inline function(as I told earlier) is defined in another class. Inking to there is fine, just include header files. I guaranteed that it is work fine. So basically this involve with three classes. I'll explain it much as follows,

              CMsgRecorder& GetMsgRecorder(void);

              defined in CFocusGroup.h

              m_pCtlAgent->GetMsgRecorder().SetGroupState('R');

              defined in CCmdLine.cpp

              SetGroupState()

              used in CMsgRecorder.cpp and CMsgRecorder.h

              I appreciate your help all the time... Eranga :)

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

              Sorry, but it is very confusing trying to understand you :~ Why do you talk about inline functions if it has nothing to do with the problem and if you can guarantee that it works fine. You really need to explain your problem in a way that it is clear for people that don't see your screen. Anyway here is your problem: you have defined a class CMsgRecorder in which you have a function (SetGroupState). You use this function somewhere else in the code and it compiles without error but fail for the linking. This is important because it tells you that the function declaration is found (so there is no problem with include files whatsoever, otherwise it would fail at compilation). The problem is that when the linker is doing its job, it cannot find a body (or a definition) for the function. You showed me the body of the function, so you've written one. The only possible 'solution' I have in mind is that you actually forgot to add the cpp file of CMsgRecorder to your project (meaning that this file is not compiled and then of course the linker cannot find the function). Are you sure it is contained in the files of your project ?

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

              C 1 Reply Last reply
              0
              • C Cedric Moonen

                Sorry, but it is very confusing trying to understand you :~ Why do you talk about inline functions if it has nothing to do with the problem and if you can guarantee that it works fine. You really need to explain your problem in a way that it is clear for people that don't see your screen. Anyway here is your problem: you have defined a class CMsgRecorder in which you have a function (SetGroupState). You use this function somewhere else in the code and it compiles without error but fail for the linking. This is important because it tells you that the function declaration is found (so there is no problem with include files whatsoever, otherwise it would fail at compilation). The problem is that when the linker is doing its job, it cannot find a body (or a definition) for the function. You showed me the body of the function, so you've written one. The only possible 'solution' I have in mind is that you actually forgot to add the cpp file of CMsgRecorder to your project (meaning that this file is not compiled and then of course the linker cannot find the function). Are you sure it is contained in the files of your project ?

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

                C Offline
                C Offline
                CodingLover
                wrote on last edited by
                #9

                Yes, all files are in my project. Also, all of these happened at compile time, not at the runtime. :(

                I appreciate your help all the time... Eranga :)

                C 1 Reply Last reply
                0
                • C CodingLover

                  Yes, all files are in my project. Also, all of these happened at compile time, not at the runtime. :(

                  I appreciate your help all the time... Eranga :)

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

                  Eranga Thennakoon wrote:

                  Also, all of these happened at compile time, not at the runtime

                  Well, I know that. That's wath I'm talking about in my previous post.

                  Eranga Thennakoon wrote:

                  Yes, all files are in my project.

                  Sorry, but then I can't help anymore. I explained the problem clearly in my previous message, so at least you have some clues to investigate. Are you absolutely sure that the .cpp file is in your project ? I'm not talking about including the header file with an "include" statement.

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

                  C 1 Reply Last reply
                  0
                  • C Cedric Moonen

                    Eranga Thennakoon wrote:

                    Also, all of these happened at compile time, not at the runtime

                    Well, I know that. That's wath I'm talking about in my previous post.

                    Eranga Thennakoon wrote:

                    Yes, all files are in my project.

                    Sorry, but then I can't help anymore. I explained the problem clearly in my previous message, so at least you have some clues to investigate. Are you absolutely sure that the .cpp file is in your project ? I'm not talking about including the header file with an "include" statement.

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

                    C Offline
                    C Offline
                    CodingLover
                    wrote on last edited by
                    #11

                    Cedric Moonen wrote:

                    Are you absolutely sure that the .cpp file is in your project ?

                    Yes pal, this is sure. I've double checked after you ask that pal. :((

                    I appreciate your help all the time... Eranga :)

                    C 1 Reply Last reply
                    0
                    • C CodingLover

                      Cedric Moonen wrote:

                      Are you absolutely sure that the .cpp file is in your project ?

                      Yes pal, this is sure. I've double checked after you ask that pal. :((

                      I appreciate your help all the time... Eranga :)

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

                      Is it one single project or is it a solution containing several sub-projects ? Is it a big project ? If no, would it be possible that you send everything to me by mail (only the source and header files and the solution and project files: sln and vcproj if you are using VC2005)? You can send it to cedric_moonen at hotmail dot com. Put all those files (and only those) in a zip file. I can have a look and see if I can fix the problem.

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

                      C 1 Reply Last reply
                      0
                      • C Cedric Moonen

                        Is it one single project or is it a solution containing several sub-projects ? Is it a big project ? If no, would it be possible that you send everything to me by mail (only the source and header files and the solution and project files: sln and vcproj if you are using VC2005)? You can send it to cedric_moonen at hotmail dot com. Put all those files (and only those) in a zip file. I can have a look and see if I can fix the problem.

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

                        C Offline
                        C Offline
                        CodingLover
                        wrote on last edited by
                        #13

                        Thanks pal, it is collection of sub-projects. Actually there is 7 sub-projects. I've done all the things learn until now in a same project to use as a single one. Now the size is over 30MB, even delete all debug folders. I'll try to remove all un-wanted projects and send it to you. Also I used Visual Studio .Net 2003.

                        I appreciate your help all the time... Eranga :)

                        C 1 Reply Last reply
                        0
                        • C CodingLover

                          Thanks pal, it is collection of sub-projects. Actually there is 7 sub-projects. I've done all the things learn until now in a same project to use as a single one. Now the size is over 30MB, even delete all debug folders. I'll try to remove all un-wanted projects and send it to you. Also I used Visual Studio .Net 2003.

                          I appreciate your help all the time... Eranga :)

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

                          Eranga Thennakoon wrote:

                          it is collection of sub-projects.

                          That is probably your problem. This class (the CMsgRecorder) is part of one of your project but you try to use it in another one. The compiler can find the header file of this file but once it needs to link to it, it fails because it is not part of the same project. Am I right or not ? You cannot do that, you cannot use classes from other projects. It is not because it is in the same solution that you can use everything from everywhere. It is exactly the same as if the projects were not in the same solution. Putting them together is just a matter of convenience, nothing else.

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

                          C 1 Reply Last reply
                          0
                          • C Cedric Moonen

                            Eranga Thennakoon wrote:

                            it is collection of sub-projects.

                            That is probably your problem. This class (the CMsgRecorder) is part of one of your project but you try to use it in another one. The compiler can find the header file of this file but once it needs to link to it, it fails because it is not part of the same project. Am I right or not ? You cannot do that, you cannot use classes from other projects. It is not because it is in the same solution that you can use everything from everywhere. It is exactly the same as if the projects were not in the same solution. Putting them together is just a matter of convenience, nothing else.

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

                            C Offline
                            C Offline
                            CodingLover
                            wrote on last edited by
                            #15

                            Cedric Moonen wrote:

                            That is probably your problem. This class (the CMsgRecorder) is part of one of your project but you try to use it in another one. The compiler can find the header file of this file but once it needs to link to it, it fails because it is not part of the same project. Am I right or not ?

                            Yes, I think so. Since I used large number of projects, it can be happened. Now first thing I'm going to do is, remove this project from the existing one and test. Let see what I can found.

                            I appreciate your help all the time... Eranga :)

                            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