User Profile

Collapse

Profile Sidebar

Collapse
sgurukrupagmailcom
sgurukrupagmailcom
Last Activity: Apr 27 '12, 03:15 PM
Joined: Apr 26 '08
Location: Bangalore, India
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Thanks. How did I miss that sentence in the man pages?
    :-)
    See more | Go to post

    Leave a comment:


  • Is the 'read' unix system call interface goofed up?

    Hi,

    The prototype for the 'read' system call as given in the POSIX standard reads like this:

    Code:
    #include <unistd.h>
    
    ssize_t read(int filedes, void* buf, size_t nbytes);
    This system call returns the number of bytes read from the file associated with the file descriptor 'filedes'.

    The odd thing about it is that we need to specify the number of bytes to be...
    See more | Go to post

  • Hmmm... I need some time to work on what Savage, Banfa and weaknessforcats have suggested.. I think I need to understand the different aspects of class inheritance as remarked by weaknessforcats .

    Can you suggest a good book or article that would explain all the intricacies of class inheritance and template design ? I have Bjarne Stroustrup's "C++ Programming Language - 3rd edition". But it's quite terse and needs to be read...
    See more | Go to post

    Leave a comment:


  • Banfa suggested moving the enum out of struct, that is surely a solution. But when I have a number of classes like 'struct x', each one having its own 'enum OPTIONS', then I would end up with a corresponding number of enums. I would, then, have to devise names for each of the enums. Also the relationship between the enum and its corresponding class wouldn't be evident. There is one more severe restriction of having many enums like this in the same...
    See more | Go to post

    Leave a comment:


  • Hi,

    I am sorry, the last error reported by the GNU compiler is due to a missing semicolon on the line:

    Code:
    enum OPTIONS { YES, NO }
    See more | Go to post

    Leave a comment:


  • sgurukrupagmailcom
    started a topic cyclic dependency in template instantiation
    in C

    cyclic dependency in template instantiation

    Hi,

    When searching for a solution to my problem I stumbled upon 'Curiously Recurring Template Pattern' see link.

    This is how the pattern looks:
    Code:
    template < typename T >
    struct y
    {
    } ;
    
    struct x : public y < x >
    {
    } ;
    But my problem is that I want to access a member of the derived class in the instance of the base class:
    ...
    See more | Go to post

  • Hi,

    The singleton design pattern was an interesting article on controlling the number of instances that a user of the class can create.

    The warning that RRick gave near the beginning of the thread about throwing exception as pointer to an object is something that we need to heed. It's better to drop the idea of throwing pointer to objects, otherwise it would lead to increased complexity in maintaining the code.
    ...
    See more | Go to post

    Leave a comment:


  • Hi RRick,

    You got to the root of my problem. I am being too obsessive about not allowing others to create instances of my exception class. It's not going to hurt anyone, if they do. However on the positive side my quest did spark off an instructive discussion at the comp.lang.c++ group. click here to see.
    This thread does answer the questions raised here. Rick, I have got a few more things to say about handling exceptions in C++...
    See more | Go to post

    Leave a comment:


  • The actual problem that I am trying to solve

    Hi,

    Well, the reason I am trying to solve this weird problem is because of the following design that I want to implement.

    I have an 'exception' class that no other function must be able to throw except a select group of functions. I want the compiler to prohibit people who use my code the capability of throwing instances of my exception class. However they will...
    See more | Go to post
    Last edited by sgurukrupagmailcom; May 5 '09, 06:24 AM. Reason: Wanted to add a descriptive title

    Leave a comment:


  • Hi,

    Sorry folks. I hadn't actually tried compiling the above code with the change included. The change that we thought would work was: throwing a pointer to 'struct m' rather than throwing an instance of 'struct m' itself. To be more clear what I am trying to say is that the code below
    Code:
    struct m
    {
    	void n ( ) throw ( m * ) ;
    	int val ;
    } ;
    
    int main ( )
    {
    return 0 ;
    ...
    See more | Go to post
    Last edited by sgurukrupagmailcom; May 4 '09, 03:58 AM. Reason: I wrongly referred to 'g++' as 'gcc'

    Leave a comment:


  • Hi weaknessforcats ,

    Thanks for your kind reply. I knew that there should be a simple workaround for this design problem. The solution that you suggested is very simple, I just throw a pointer to the struct instead of the actual object.

    Warm Regards,
    Gaura
    See more | Go to post

    Leave a comment:


  • sgurukrupagmailcom
    started a topic Cyclic dependency in throw declaration
    in C

    Cyclic dependency in throw declaration

    Hi,

    I am unable to get the following to compile
    Code:
    struct m
    {
            void n ( ) throw ( m ) ;
    } ;
    
    int main ( )
    {
    }
    I am using g++ ( GNU version of c++ compiler ) to compile. It throws the following error:
    Code:
    m.cpp:3: error: invalid use of incomplete type 'struct m'
    m.cpp:2: error: forward declaration of 'struct m'
    See more | Go to post

  • sgurukrupagmailcom
    replied to Using variables inside for loop
    in Java
    Thank you, for your kind reply.

    Warm Regards,
    Ganesh
    See more | Go to post

    Leave a comment:


  • sgurukrupagmailcom
    started a topic Using variables inside for loop
    in Java

    Using variables inside for loop

    Hi,

    I haven't come accross an elegant solution to a design problem that I show below. Have a look at the piece of code here:
    Code:
     
    class Exc
    {
     Exc ()
     {
      System.out.println ("Haribol");
     }
     
     static public void main ( final String [] args )
     {
      for ( int i = 0 ; i < 4 ; ++ i )
      {
       Exc e = new Exc ();
      }
     }
    }
    ...
    See more | Go to post
No activity results to display
Show More
Working...