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#
  4. C++ class defined in header file. Implementation in C# ?

C++ class defined in header file. Implementation in C# ?

Scheduled Pinned Locked Moved C#
c++questioncsharphelp
2 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.
  • C Offline
    C Offline
    crushinghellhammer
    wrote on last edited by
    #1

    I'm trying to port some old C++ code to C#. I have a few classes that were defined in a ".h" file. Their constructors and member variables were defined in the corresponding .cpp file. What is the best way to port this file to C#. More specifically: 1. I assume that the class, its constructor and methods are all defined together as follows: class DSP { // constructor // methods } Is this correct? 2. The original C++ listing in the .h file is as follows: class DSP { public: // public variables protected: //constructor // destructor // private variables void SomeMethod() }; These public variables need to be properties that can be assigned to. Therefore in the C# implementation, do I need to define these fields with "get" and "set" properties? I know these are very elementary questions, but I haven't ported any C++ code over to C# before, and I appreciate your help!

    C 1 Reply Last reply
    0
    • C crushinghellhammer

      I'm trying to port some old C++ code to C#. I have a few classes that were defined in a ".h" file. Their constructors and member variables were defined in the corresponding .cpp file. What is the best way to port this file to C#. More specifically: 1. I assume that the class, its constructor and methods are all defined together as follows: class DSP { // constructor // methods } Is this correct? 2. The original C++ listing in the .h file is as follows: class DSP { public: // public variables protected: //constructor // destructor // private variables void SomeMethod() }; These public variables need to be properties that can be assigned to. Therefore in the C# implementation, do I need to define these fields with "get" and "set" properties? I know these are very elementary questions, but I haven't ported any C++ code over to C# before, and I appreciate your help!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      C# classes do not have header files, pretty much anything in the header can be discarded. The declaration of functions in C# is the same as the definition, and everything can automatically see the namespaces in the project, without having to include anything. Yes, the best way to set properties is with get/set methods, then you can make variables that can be got and not set, and vice versa, if needed. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      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