Code:
void f(const vector<int>& a, vector<float>& b) { typedef decltype(a[0]*b[0]) Tmp; for (int i=0; i < b.size(); ++i) { auto p0 = new auto(a[i]*b[i]); auto p1 = new decltype(a[i]*b[i]); *p0=a[i]*b[i]; *p1=a[i]*b[i]; cout<<*p0<<endl;
void f(const vector<int>& a, vector<float>& b) { typedef decltype(a[0]*b[0]) Tmp; for (int i=0; i < b.size(); ++i) { auto p0 = new auto(a[i]*b[i]); auto p1 = new decltype(a[i]*b[i]); *p0=a[i]*b[i]; *p1=a[i]*b[i]; cout<<*p0<<endl;
typedef const char* CCARRY[10]; char * p="Hello"; p = "Merry"; CCARRY arr1={p};//OK using the type of char * to initialize to type of const char * arr1[0]=p;//OK,assignment CCARRY arr2[5]={arr1};//1**compile error:cannot convert 'const char**' to 'const char*' in initialization CCARRY arr3[5]={*arr1};//3**ok,right
#include <iostream> using namespace std; struct test { test(int ii);//I used to think only
typedef void (f)(void);//it is not (*f) void funptr(f parafun) { parafun(); } void fun() { printf("test\r\n"); }
int main() { funptr(fun);//1.ok f parafun=fun;//2.error return 0; }
template<typename X> class Base{ public: int basefield; typedef int T; }; template <typename T> class DD:Base<T>{ public: void
#include <iostream> using namespace std; struct BaseWithPureFunction { virtual void PureFunc() = 0; void CallPureFunc() { PureFunc(); } BaseWithPureFunction();
BaseWithPureFunction::BaseWithPureFunction() { /* Call pure-virtual directly. Running well.I puzzled. */ PureFunc(); }
#include <iostream> using namespace std; class BaseWithPureFunction { public: virtual void PureFunc() = 0; void CallPureFunc() { PureFunc(); } BaseWithPureFunction()
list <int> a; a.push_back(10); a.push_back(15); int* po; list <int>::reverse_iterator iter=a.rbegin(); cout<<"value of iter point to:"<<*iter<<endl; po=&(*iter); a.push_back(9); cout<<"value of iter point to:"<<*iter<<endl; cout<<"value of po point to:"<<*po<<endl;
Leave a comment: