Question
-
Topic
-
Learning Object Oriented C
LockedI’m trying to teach myself Object Oriented C++ (I know Funktion Oriented C and C++, and Object Oriented C# and Java) but I’m having a hard time grasping header files.
I have written a small object oriented “hello world” program in C#, and I’m hoping someone here would translate it to the coresponding object oriented c++ code, with header files and such, as it would help me a lot, in understanding the concept.
Thanks a lot in advance!
– Stephenmy code is:
// Name.cs
using System;
namespace ConsoleApp
{
class Name
{
private String myName = “nothing”;
public Name() {}
public Name(String newName)
{
this.myName = newName;
}
public String getName()
{
return myName;
}
}
}// Program.cs
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Name myName = new Name(“Stephen”);
Console.Out.WriteLine(“Hello “+myName.getName()+”!”);
}
}
}