User Profile

Collapse

Profile Sidebar

Collapse
evenstar
evenstar
Last Activity: Jun 20 '12, 06:39 AM
Joined: Jul 4 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • evenstar
    started a topic difference between auto and decltype in c++0x
    in C

    difference between auto and decltype in c++0x

    I'm having trouble with auto and decltype.
    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;
    ...
    See more | Go to post

  • evenstar
    replied to how to understand this typedef
    in C
    If const char* CCARRY[10].then CCARRY is an array of 10 char* that are const.And CCARRY is an array name

    But,in my code it is typedef const char* CCARRY[10].And CCARRY is a type name.
    See more | Go to post

    Leave a comment:


  • evenstar
    started a topic how to understand this typedef
    in C

    how to understand this typedef

    Hi,
    Code:
      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
    ...
    See more | Go to post

  • About using nonstatic data member as a default argument

    As I know"A nonstatic data member may not be used as a default argument because its value cannot be used independently of the object of which it is a part. Using a nonstatic data member as a default argument provides no object from which to obtain the member's value and so is an error."
    But...
    Code:
    #include <iostream>
    using namespace std;
    
    struct test
    {
    	test(int ii);//I used to think only
    ...
    See more | Go to post

  • evenstar
    replied to about typedef the name of a function
    in C
    I really want to know what is "typedef void (f)(void)"but not "*pf"
    See more | Go to post

    Leave a comment:


  • evenstar
    started a topic about typedef the name of a function
    in C

    about typedef the name of a function

    Code:
    typedef void (f)(void);//it is not (*f)
    
    void funptr(f parafun)
    {
         parafun();
    }
    
    
    
    void fun()
    {
       printf("test\r\n");
    }
    How to understand that:
    Code:
    int main()
    {
       funptr(fun);//1.ok
       f parafun=fun;//2.error
       return 0;
    }
    See more | Go to post

  • evenstar
    replied to About finding name in dependent base classes
    in C
    Anybody know?
    See more | Go to post

    Leave a comment:


  • evenstar
    started a topic About finding name in dependent base classes
    in C

    About finding name in dependent base classes

    Hi every body,
    It said that standard C++ says nondependent names are not looked up in dependent base classes,in c++ template 9.4.2..
    Code:
    template<typename X>
    
      class Base{
    
      public:
    
      int basefield;
    
      typedef int T;
    
      };
    
      template <typename T>
    
      class DD:Base<T>{
    
      public:
    
      void
    ...
    See more | Go to post

  • evenstar
    replied to Call virtual functions during construction
    in C
    I finally understand.
    Thank you very much indeed .
    See more | Go to post

    Leave a comment:


  • evenstar
    replied to Call virtual functions during construction
    in C
    ...My question has been answered?May be my expression is unclear.
    Please look at the question again,and make sure what I want to know.Thank you.
    Code:
    #include <iostream>
    using namespace std;
    
    struct BaseWithPureFunction
    { 
        virtual void PureFunc() = 0;
    
        void CallPureFunc()
        {
            PureFunc();
        }
    
        BaseWithPureFunction();
    ...
    See more | Go to post

    Leave a comment:


  • evenstar
    replied to Call virtual functions during construction
    in C
    Thanks again for your help.
    At the point the base class constructor is invoked from the derived class constructor, the object ex is not yet of type BaseEx.The base class constructor initializes the BaseWithPureFun ction subobject within ex to behave like a BaseWithPureFun ction object. Therefore, when the virtual PureFunc is called in base class constructor, it binds to BaseWithPureFun ction::PureFunc .According to holy,it should lead a error.But...
    See more | Go to post

    Leave a comment:


  • evenstar
    replied to Call virtual functions during construction
    in C
    The fact was that I called the function of PureFunc directly and by the CallPureFunc function indirectly had different results.One is running well,but the other cause a error.Tow ways both invoked PureFunc function by the same types of 'this' pointer that pointed to base type,but they had different results.
    Is there any ambiguous?
    See more | Go to post

    Leave a comment:


  • evenstar
    replied to Call virtual functions during construction
    in C
    Thanks for your help.
    I know during construction the base virtual function will be called.So What you said is not that I want to know.
    I want to find the answer :why this part of code can go well:
    Code:
    BaseWithPureFunction::BaseWithPureFunction()    
    {  
        /* 
          Call pure-virtual directly. 
          Running well.I puzzled. 
        */ 
              PureFunc();    
      }
    ...
    See more | Go to post

    Leave a comment:


  • evenstar
    started a topic Call virtual functions during construction
    in C

    Call virtual functions during construction

    hello every body,
    I know I shouldn't call virtual functions during construction or destruction.
    Code:
    #include <iostream>
    using namespace std;
    
    class   BaseWithPureFunction 
    { 
    public: 
        
    
        virtual   void   PureFunc()   =   0; 
        void   CallPureFunc()   
        { 
            PureFunc();     
        } 
    
        BaseWithPureFunction()
    ...
    See more | Go to post

  • evenstar
    replied to a question of iterator
    in C
    I appreciate your help greatly,and no question now.I am so glad.
    See more | Go to post

    Leave a comment:


  • evenstar
    replied to a question of iterator
    in C
    Oh,I got it ,because of "current-1".JosAH and Banfa,I thank you very much indeed,that's very kind of you.

    The book also says:
    "avoid access violations,curr ent points to the element after the one the reverse_iterato r refers to.This implies that * returns the value * (current-1) and..."

    But how to access violations?The rend(one-before-the-beginning)eleme nt can stop it.So,i don't think uisng...
    See more | Go to post

    Leave a comment:


  • evenstar
    replied to a question of iterator
    in C
    "it actually points past the end of the list"?Oh, what has happened ?
    See more | Go to post

    Leave a comment:


  • evenstar
    replied to a question of iterator
    in C
    Thanks very much for your help,but it is a list,not a vector.
    See more | Go to post

    Leave a comment:


  • evenstar
    started a topic a question of iterator
    in C

    a question of iterator

    Code:
    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;
    ...
    See more | Go to post

  • evenstar
    replied to a question of pointer
    in C
    Thank you all for your attention!
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...