how do i create a class in c++ in swift

To create a class in C++, you use the class keyword followed by the class name and the class definition contained within curly braces:

class MyClass {
  // class definition goes here
};
51 chars
4 lines

In Swift, you'll use the class keyword and the class name, but Swift uses two curly braces to define the class body:

main.swift
class MyClass {
  // class definition goes here
}
50 chars
4 lines

Here's an example of a class definition in C++ that includes a constructor:

class MyClass {
public:
  MyClass(int num) {
    // constructor definition goes here
  }
};
92 chars
7 lines

And here's an example in Swift that includes a constructor:

main.swift
class MyClass {
  init(num: Int) {
    // constructor definition goes here
  }
}
81 chars
6 lines

Note that the syntax for defining a constructor is slightly different between the two languages. In C++, you define the constructor as a function with the same name as the class. In Swift, you use the init keyword followed by any arguments to the constructor.

gistlibby LogSnag