Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: maluk
  • Content: Threads
  • Order by date
  1. maluk

    Implementing C# properties in C++

    Here's a way you could implement C#'s property concept: We want the public member variable INITIALIZED to be read-only. Here's how to implement it. class A { public: A() : INITIALIZED(initialized_) { initialized_ = 100; } void reconf(int i) {...
  2. maluk

    What is meant by this?

    I found a declaration like this: void h(int()); What does this mean? Is that argument a pointer to function or what? If it was intended as a pointer to function then should it be declared like this: void h(int (*)()); Rome did not create a great empire by having meetings, they did it...
  3. maluk

    A pthread_cancel problem

    Hello all! I am experimenting with pthreads. Now I have encountered an unexpected behavior (at least I think it is). The code is show below: #include <iostream> #include <pthread.h> using namespace std; void* task(void* arg) { cout << "Starting task" << endl; for(int count =...
  4. maluk

    STL multimap value_type compare

    Hi all! The STL multimap accepts duplicate keys such that the following entry is valid for a multimap: KEY VALUE foo bar jack jill Now the problem is, multimap also accepts duplicate entries such that if I would add another foo, bar pair the multimap will accept it. So...
  5. maluk

    Why are STLs not thread-safe?

    I have read in most articles that STL is not thread-safe or should not be used in multi-threading? Why? What are other alternatives or how should one make a thread-safe STL? Rome did not create a great empire by having meetings, they did it by killing all those who opposed them. - janvier -
  6. maluk

    Constructors and Exceptions

    Hi guys! What is the corrext way to handle exceptions during construction of a member object? A code snippet is give below: class SomeException {}; class A { public: A() throw(SomeException) { if(...) { throw SomeException(); }...
  7. maluk

    Getting the IP address of a network interface

    Hi! I am having a bit of a problem getting the local address of my computer. For example, my IP is something like 192.68.1.100. When a do a ifconfig -a, I can see that eth0 is assigned the said IP. So naturally, I tried getting the IP using the socket APIs. However, no matter how hard I try, I...
  8. maluk

    returned reference to a vecto and resident memory usage

    I have code that returns a reference to a member variable. The member variable is a vector of a certin class. This class consumes 5848 or more bytes. The process is like this, I loop on the number of objects in the vector described above using iterators in a for() loop. So I have a class like...
  9. maluk

    Does this cause a mem leak?

    Assuming I have a vector and an iterator for it. Assuming also that the vector contains elements. Also assume a function fxn() exists. ... struct A; void fxn(A& theA); ... vector<A> vectorA; vector<A>::iterator iterA; ... ... for(iterA = vectorA.begin(); iterA != vectorA.end(); ++iterA) {...
  10. maluk

    POSIX thread problem

    Hi all! I got a problem regarding POSIX threads specifically pthread_mutex_lock and pthread_mutex_unlock. Here is the code: #include <iostream> #include <pthread.h> #include <unistd.h> using namespace std; void* doRunA(void* arg); class A { public: A() : a(0) { } void Run() {...
  11. maluk

    STL containers

    I need help! Why won't this work? deque<ContactInfo>::iterator contact_info_iter; for(contact_info_iter = contact_list.begin(); contact_info_iter != contact_list.end(); contact_info_iter++) { contact_list.erase(contact_info_iter); } Rome did not create a great empire by having meetings...
  12. maluk

    What is __attribute__?

    What is an __attribute__? What is this good for? What things similar to __attribute__ should I know in gcc? Rome did not create a great empire by having meetings, they did it by killing all those who opposed them. - janvier -
  13. maluk

    signal handling using sigaction

    Using the system calls related to sigaction() and signal set manipulation, i.e. sigaddset(), sigfillset(), etc., how would I implement a signal handler to block only SIGUSR1 and SIGUSR2 and ignore other signals? I tried this without using sigprocmask() by first creating a signal set to be...
  14. maluk

    A static object

    Can someone tell me the effects of the static object on the statements that are numbered? SomeCode.cpp #include "../RSS/RSSInfo.h" using RSS::RSSInfo ; static RSSInfo fxnOne(void) ; // ??? (1) static RSSInfo& fxnTwo(void) ; // ??? (2) static RSSInfo rss_1 ; // ??? (3) int main() {...
  15. maluk

    Calling a constructor from another constructor

    Will it be possible to call a contructor from another constructor in a single class? Rome did not create a great empire by having meetings, they did it by killing all those who opposed them. - janvier -
  16. maluk

    Why won't this work?

    Why won't this work? class Base { public: Base() { } Base(const char* msg) { } } ; class Sub : pulic Base { Sub() { } Sub(const char* msg) { Base::Base(msg) ; } } ; Why isn't the above code the same as this one (that works): class Base {...
  17. maluk

    Assignment operator

    What would happen if the overloaded assignment operator returns an object by value rather than by reference? Meaning, the 'operator=' is implemented like below: // Assume there is class named 'B' with a single member // variable named 'int i' B B::operator=( const B& b ) { B my_b ...
  18. maluk

    What's the difference?

    Suppose I have two functions, one returns a reference to an object and the other returns an object by value. See below: // Assume 'B' is a well-defined class B& fn(B& b) // returns an object reference { b.i++ ; return b ; } B fn2(B& b) // returns an object by value { b.i++...
  19. maluk

    Lvalues and rvalues, cv, cv-qualifed, cv-unqualified etc.

    What are lvalues and rvalues as stated in the C++ standard? Also, what is cv-qualified as stated in the C++ standard? I just know that lvalues can be found on the left side of an operator and rvalues on the right. Also they say lvalues are objects. What else does lvalue and rvalue mean? Same...
  20. maluk

    About assigning to references

    I am reading about C++ references. I came about the code that cannot compile. Here is the code: int& i = 1 ; // this will cause a compiler error const int& j = 1 ; // this works On my compiler, it says Initialization of non-const reference type 'int&' from rvalue of type 'int'. Can...

Part and Inventory Search

Back
Top