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. i know this has to be a simple question.

i know this has to be a simple question.

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 2 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.
  • J Offline
    J Offline
    jafrazee
    wrote on last edited by
    #1

    i have 2 classes. the first class is a crecordview class (Cmain) that holds my data, and is the main dialog for my program. the second class is a cdialog (Creport), and is opened modal from the crecordview class dialog. my problem is i have created a class function in the Cmain labeled Cmain::GetData(). this function works fine if i run it from Cmain dialog. I can not find a way to call it from Creport. How can this be done. If i include the header for Cmain in Creport i get all kinds of errors. thank you for any help

    J 1 Reply Last reply
    0
    • J jafrazee

      i have 2 classes. the first class is a crecordview class (Cmain) that holds my data, and is the main dialog for my program. the second class is a cdialog (Creport), and is opened modal from the crecordview class dialog. my problem is i have created a class function in the Cmain labeled Cmain::GetData(). this function works fine if i run it from Cmain dialog. I can not find a way to call it from Creport. How can this be done. If i include the header for Cmain in Creport i get all kinds of errors. thank you for any help

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      Have you included the Cmain header in creport.h or creport.cpp? If the former, try the latter. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      J 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        Have you included the Cmain header in creport.h or creport.cpp? If the former, try the latter. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        J Offline
        J Offline
        jafrazee
        wrote on last edited by
        #3

        i tried both and get the same errors c:\src\cmain.h(75) : error C2143: syntax error : missing ';' before '*' c:\src\cmain.h(75) : error C2501: 'Cmaindoc' : missing storage-class or type specifiers c:\src\cmain.h(75) : error C2501: 'GetDocument' : missing storage-class or type specifiers C:\src\creport.cpp(507) : error C2248: 'Cmain::Cmain' : cannot access protected member declared in class 'Cmain' c:\src\cmain.h(28) : see declaration of 'Cmain::Cmain'

        J 1 Reply Last reply
        0
        • J jafrazee

          i tried both and get the same errors c:\src\cmain.h(75) : error C2143: syntax error : missing ';' before '*' c:\src\cmain.h(75) : error C2501: 'Cmaindoc' : missing storage-class or type specifiers c:\src\cmain.h(75) : error C2501: 'GetDocument' : missing storage-class or type specifiers C:\src\creport.cpp(507) : error C2248: 'Cmain::Cmain' : cannot access protected member declared in class 'Cmain' c:\src\cmain.h(28) : see declaration of 'Cmain::Cmain'

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          Are you including cmain.h after stdafx.h? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          J 1 Reply Last reply
          0
          • J jafrazee

            directly after actually

            J Offline
            J Offline
            Joaquin M Lopez Munoz
            wrote on last edited by
            #5

            Could you cut and post from the beginning of creport.cpp to the offending #include? It ought be a simple thing, but I guess my inspiration is failing me :) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

            J 1 Reply Last reply
            0
            • J Joaquin M Lopez Munoz

              Are you including cmain.h after stdafx.h? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

              J Offline
              J Offline
              jafrazee
              wrote on last edited by
              #6

              directly after actually

              J 1 Reply Last reply
              0
              • J Joaquin M Lopez Munoz

                Could you cut and post from the beginning of creport.cpp to the offending #include? It ought be a simple thing, but I guess my inspiration is failing me :) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

                J Offline
                J Offline
                jafrazee
                wrote on last edited by
                #7

                all i have on the top of my file is // creport.cpp : implementation file // #include "stdafx.h" #include "cmain.h" #include "creport.h" //////////////////////i have also tried to creport.h before cmain.h i did find the following article on msdn. i have not made any since of it yet though. HOWTO: Declare Classes That Refer to Each Other Q136005 -------------------------------------------------------------------------------- The information in this article applies to: The Microsoft C/C++ Compiler (CL.EXE) Microsoft Visual C++ for Windows, 16-bit edition, versions 1.0, 1.5, 1.51, 1.52 Microsoft Visual C++, 32-bit Editions, versions 1.0, 2.0, 2.1, 2.2, 4.0, 4.1, 5.0, 6.0 -------------------------------------------------------------------------------- SUMMARY In C++, you may need to have two classes that contain data members that refer to the other class as in this example: class B { A * x; }; class A { B * x; }; This article shows by example how to declare two classes that contain pointers to the other class. The two classes (A and B) are derived from other classes (C and D) to better demonstrate this issue. If the two classes are not declared correctly, errors such as the following can occur: test1.h(8) : error C2501: 'B' : missing decl-specifiers test1.h(8) : error C2143: syntax error : missing ';' before '*' test1.h(8) : error C2501: 'x' : missing decl-specifiers MORE INFORMATION Sample Code /* Compile options needed: none */ //================================ // test1.h //================================ #ifndef _a_ #define _a_ class B; class A : public D { B * x; }; #endif //================================ // test2.h //================================ #ifndef _b_ #define _b_ class A; class B : public C { A * y; }; #endif //================================= // test.cpp //================================= class C { int q; }; class D { int p; }; #include "test1.h" #include "test2.h" void main(void) { } Additional query words: 8.00 8.00c 9.00 9.10

                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