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. C2084

C2084

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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    error C2084: function 'void __thiscall Stock::setNumOfOutShares(int &)' already has a body thank you ! :((

    P 1 Reply Last reply
    0
    • L Lost User

      error C2084: function 'void __thiscall Stock::setNumOfOutShares(int &)' already has a body thank you ! :((

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      If you have implemented the function in a file header, you will need to add 'inline' to the beginning of you function declaration, otherwise move the function implementation to a .cpp file.

      M 1 Reply Last reply
      0
      • P Paul M Watt

        If you have implemented the function in a file header, you will need to add 'inline' to the beginning of you function declaration, otherwise move the function implementation to a .cpp file.

        M Offline
        M Offline
        marouane miftah el kheir
        wrote on last edited by
        #3

        can you please tell me how do i write a regular class ? i did not have this problem be4 but when i put the class definitions(those were my .cpp files), i added them to my class declarations (.H files) i got hundreds of errors C2084?? can you tell please tell me what is the right way to write classes? and what do you mean by add 'inline'to the beginnig to the function? can you give an example? thank you so much

        P 1 Reply Last reply
        0
        • M marouane miftah el kheir

          can you please tell me how do i write a regular class ? i did not have this problem be4 but when i put the class definitions(those were my .cpp files), i added them to my class declarations (.H files) i got hundreds of errors C2084?? can you tell please tell me what is the right way to write classes? and what do you mean by add 'inline'to the beginnig to the function? can you give an example? thank you so much

          P Offline
          P Offline
          Paul M Watt
          wrote on last edited by
          #4

          There are a number of ways to write a class. I think that how you do it depends on the current situation. Alot of times programming style simply depends on your tastes. I have developed code with alot of other people, and they all like to organize their classes in their own ways. One thing to keep in mind though, is that alot of people may see your header files if they are going to use your classes, the implementation files are rarely ever seen. With this in mind, the code that you do not want other people to see should be placed in the .cpp file. If you have a large class with complicated implmentations I would create a header file with the class and function declarations, then place the implementations in the .cpp file. If you class has a lot of simple get and set functions, these are good candidates for inline functions. For instance: class Stock { CHAR* GetName () { return name; } }; or like I suggested earlier, add the inline declaration to the function implementation. class Stock { CHAR* GetName (); }; inline CHAR* Stock::GetName () { return name; } inline functions will make the entire piece of code that is created for the function will be compiled inline where the function would normally be called instead of actually calling the function. The only drawbacks to inline functions is that if you do it too often, the size of your program will become bloated. Use function inlining judiciously. The reason why you get a million errors with out the inline declaration, is because every file that includes your header file recompiles the functions that should be declared inline, and when the linker tries to link all of these files it finds multiple implementations for the function. Using inline forces only one implementation.

          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