[b]原帖地址:[/b] [url]http://www.devdiv.net/thread-9296-1-1.html[/url]
[b]作者:[/b] Vincent
iphone的开发比较好的支持了c++的一些特性,文件读写,输入,stl, 包括linux的多线程都得到了比较好的支持,要在iphone上使用c++, 只要把包含c++代码,和调用了c++代码的文件名改成.mm就可以了。
测试case
[b]xx.h[/b]
#include <iostream>
#include <vector>
#include <list>
#include <ext/hash_map>
#include <string>
#include <fstream>
#include <pthread.h>
using namespace std;
void* (*function)(void*);
void* thread(void*)
{
int i = 0;
for(i = 0 ;i< 3;i++)
{
}
};
int testThread()
{
pthread_t id;
function = thread;
pthread_create(&id,NULL, function, NULL);
return 1;
//pthread_create(&id, NULL, (void*)(*)(void*)thread, NULL);
};
int testfile()
{
ofstream outfile("helloworld.txt");
outfile << "helloworld" << endl;
outfile.close();
};
int testStl()
{
vector<int> testvector;
testvector.push_back(1);
list<int> testlist;
testlist.push_back(2);
__gnu_cxx::hash_map<int,int> hash_maptest;
hash_maptest[1] = 12434;
};
int testfileinput()
{
ifstream infile;
infile.open("helloworld.txt");
if(!infile.is_open())
{
return -1;
}
string strtest;
infile >> strtest;
int a = 1;;
int b = 2;
int c = a+b;
};
[b]作者:[/b] Vincent
iphone的开发比较好的支持了c++的一些特性,文件读写,输入,stl, 包括linux的多线程都得到了比较好的支持,要在iphone上使用c++, 只要把包含c++代码,和调用了c++代码的文件名改成.mm就可以了。
测试case
[b]xx.h[/b]
[/code]
int testfile();
int testStl();
int testfileinput();
int testThread();
[b]xx.mm [/b]
[code="java"]
#include <iostream>
#include <vector>
#include <list>
#include <ext/hash_map>
#include <string>
#include <fstream>
#include <pthread.h>
using namespace std;
void* (*function)(void*);
void* thread(void*)
{
int i = 0;
for(i = 0 ;i< 3;i++)
{
}
};
int testThread()
{
pthread_t id;
function = thread;
pthread_create(&id,NULL, function, NULL);
return 1;
//pthread_create(&id, NULL, (void*)(*)(void*)thread, NULL);
};
int testfile()
{
ofstream outfile("helloworld.txt");
outfile << "helloworld" << endl;
outfile.close();
};
int testStl()
{
vector<int> testvector;
testvector.push_back(1);
list<int> testlist;
testlist.push_back(2);
__gnu_cxx::hash_map<int,int> hash_maptest;
hash_maptest[1] = 12434;
};
int testfileinput()
{
ifstream infile;
infile.open("helloworld.txt");
if(!infile.is_open())
{
return -1;
}
string strtest;
infile >> strtest;
int a = 1;;
int b = 2;
int c = a+b;
};