Search Results

Search found 28 results on 2 pages for 'sasayins'.

Page 2/2 | < Previous Page | 1 2 

  • How to properly assign a value to the member of a struct that has a class data type?

    - by sasayins
    Hi, Please kindly see below for the codes. Its compiling successfully but the expected result is not working. Im very confused because my initialization of the array is valid, //cbar.h class CBar { public: class CFoo { public: CFoo( int v ) : m_val = v {} int GetVal() { return m_val; } private: int m_val; }; public: static const CFoo foo1; static const CFoo foo2; public: CBar( CFoo foo ) m_barval( foo.GetVal() ){} int GetFooVal() { return m_barval; } private: int m_barval; }; //cbar.cpp const CBar::CFoo foo1 = CBar::CFoo(2); const CBar::CFoo foo2 = CBar::CFoo(3); //main.cpp struct St { CBar::CFoo foo; }; St st[] = { CBar::foo1, CBar::foo2 }; for( int i=0; i<sizeof(st)/sizeof(St); i++ ) { CBar cbar( st[i].foo ); std::cout << cbar.GetFooVal() << std::endl; } But then when I change the St::foo to a pointer. And like assign the address of CBar::foo1 or CBar::foo2, its working, like this, //main.cpp struct St { const CBar::CFoo *foo; }; St st[] = { &CBar::foo1, &CBar::foo2 }; for( int i=0; i<sizeof(st)/sizeof(St); i++ ) { CBar cbar( *st[i].foo ); std::cout << cbar.GetFooVal() << std::endl; } The real problem is. The app should output 2 3 Please advice. Many thanks.

    Read the article

  • Where to place a debug log files for my daemon app?

    - by sasayins
    Hi, I am using C language and Linux as my programming platform. I am learning how to create a daemon, and I want to create a log file so that I write a debug message in my daemon. My question is where should I put the log file in my system. Should I put it in the var folder? Please advice. Many thanks.

    Read the article

  • poll(2) doesn't empty the event queue

    - by sasayins
    Hi, Im using linux as my programming platform. I am using poll(2) to know if my device is triggering an event. The first call of poll is ok, it blocks and wait for the event to happen. But in the second poll function call, it will return but it capture the event. Below are my code ret = poll( fds, 1, 2000); //2 secs timeout if( fds[0].revents & POLLIN && ret > 0) { printf("event occur\n"); } It seems the queue/buffer is not empty, im just assuming. What do you think is the problem? Thanks.

    Read the article

< Previous Page | 1 2