User Profile

Collapse

Profile Sidebar

Collapse
DhananjayNangare
DhananjayNangare
Last Activity: Jul 4 '07, 08:16 AM
Joined: Mar 29 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • DhananjayNangare
    replied to Calling a function to retreive values
    in C
    This could be one of the solutions
    f 1(int a , inb, int& sum, int& mul)
    {
    sum=a+b;
    mul=a*b;
    }
    f 2(int c)
    {
    int sum, mul;
    int a = 10;
    int b = 20;

    f1(a,b,sum,mul) ;

    }
    See more | Go to post

    Leave a comment:


  • Hi,
    I tried it this way on vc++ 6.0
    Works fine
    #include <iostream.h>

    class myclass
    {

    public:

    myclass()
    {
    cout << "\n Defualt";
    myclass::myclas s(10);
    }
    myclass(int i)
    {
    cout <<"\n Overloaded :" <<i;
    }
    };
    void main()
    {
    myclass m;
    }...
    See more | Go to post

    Leave a comment:


  • DhananjayNangare
    replied to overloaded constructors and inheritence
    in C
    Thank you for the link. The case which you are refering is quite different from what we are discussing.
    I've tried this on VC++ 6.0 and it works absolutely fine.

    Could you please justify your statement
    "You cannot call a constructor's body in this way. " ??
    Please post the Error which you got while compling this code on g++.

    Even this is going to work
    void main()
    {
    ...
    See more | Go to post

    Leave a comment:


  • DhananjayNangare
    replied to overloaded constructors and inheritence
    in C
    Please try this code

    [code=cpp]#include <iostream>

    using namespace std;


    class base
    {
    public:
    base();
    base( char*);

    char* return_string() { return string; }
    private:
    char string[10];
    };

    class derived:public base
    {
    public:
    derived();
    ...
    See more | Go to post
    Last edited by AdrianH; May 22 '07, 01:40 AM. Reason: Please use [code=cpp][/code] tags for easier reading.

    Leave a comment:


  • DhananjayNangare
    replied to overloaded constructors and inheritence
    in C
    This should work

    derived::derive d(char* temp, int number)
    {
    base::base(temp );
    value =number;
    }
    See more | Go to post

    Leave a comment:


  • code removed as per posting guidelines

    Hope this helps

    [code=cpp]char* Rooms::getName( )
    {
    return name;
    }[/code]
    See more | Go to post
    Last edited by AdrianH; May 21 '07, 12:15 PM. Reason: code removed as per posting guidelines (see stuck thread in forum for details)

    Leave a comment:


  • DhananjayNangare
    replied to Reading string from file
    in C
    May be you can use fseek() like below
    /* fseek example */
    Code:
    #include <stdio.h>
    
    int main ()
    {
      FILE * pFile;
      pFile = fopen ( "myfile.txt" , "w" );
      fputs ( "This is an apple." , pFile );
      fseek ( pFile , 9 , SEEK_SET );
      fputs ( " sam" , pFile );
      fclose ( pFile );
      return 0;
    }
    See more | Go to post
    Last edited by Ganon11; Mar 30 '07, 11:44 AM. Reason: code tags added

    Leave a comment:


  • DhananjayNangare
    replied to Friend class - private member variable
    in C
    You can try something like this,

    Code:
    class X
    {
    	int i;
    
    public:
    	X():i(10){};
    
    	int* fn()
    	{
    		return &i;
    	}
    };
    
    void main()
    {
    	X x;
    	int* pI = x.fn();
    	cout << *pI;
    
    	
    }
    See more | Go to post
    Last edited by Ganon11; Mar 30 '07, 11:48 AM. Reason: code tags added

    Leave a comment:

No activity results to display
Show More
Working...