I have an iPhone project, in this I wanted to use c++ files. I created c++ file like below:
File->New File -> C/C++ files -> C++ File
and named it as ClassA.cpp
In ClassA.cpp
#include <iostream>
class ClassA
{
public:
int a, b;
void add();
};
void ClassA::add()
{
// printf("sdf");
}
in my viewController.mm file:
#import "ViewController.h"
#import "ClassA.cpp"
- (void)viewDidLoad
{
ClassA a;
a.add();
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
I read some posts it says me to rename .m to .mm so I renamed all .m files to .mm
And added two linker flags
-cclib -lstdc++
But It gives the following error:

You need to split the C++ portion into a header file and a
cppfile, otherwise theClassA::addwill be defined twice.ClassA.h:
ClassA.cpp:
Your .mm file: