Eg.for a program that can be done in C but not in C++?

Showing Answers 1 - 9 of 9 Answers

srinivas

  • Jul 29th, 2006
 

I think sorting can be done in C( eg: quick sort, merge sort, binary tree sort...), and not in C++.

  Was this answer useful?  Yes

swapnil gupta

  • Sep 10th, 2006
 

hi,

    please send me the answer of that question.

    THANK YOU!

  Was this answer useful?  Yes

Saurabh Shankar

  • Sep 20th, 2006
 

A classic example for a program that can be written in C and not in C++ is creating a mutlithreaded program with POSIX Thread. The POSIX thread functions have been defined in such a way that it cannot be acessed as a member function of an object. If it is required to create a thread of a memeber function of an object in C++, the only way to resolve it is create a thread of a C function which in turn calls the member of function of the desired object.

E.g.

class xyz

{

 private:

   // all variables defined here

public:

  void newthreadfunction(void Param);

};

xyz someobject; // creating a global object of class xyz

// the C function which will be created as a new thread which will access the memeber function of the object

void *NewThread(void *Parameter)

{

   someobject.newthreadfunction((void)Parameter); //call of the function

}

void main()

{

   pthread_t Thread;

  int ThreadCreated;

  ThreadCreated = pthread_create(&Thread, NewThread,(void*)3);

}

  Was this answer useful?  Yes

Neeru

  • Apr 16th, 2007
 

Sorting is also performed in C++ Also.Multithreaded is the right answer that we implement it on C but not in C++

  Was this answer useful?  Yes

viswakrishnan_m

  • Jul 7th, 2007
 

TSR( Terminate Stay Routine) programs only can run with the extension of c not cpp

  Was this answer useful?  Yes

s.prabhat

  • Aug 30th, 2007
 

its very simple to answer


eg:---
   

   main()
  {
          int class,y;
          class=8;
          y=class++;
          printf("%d",y);
          getch();

  }

 u can't run this program in c++ because  class is a keyword so it'll give the error

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions