Thursday, July 30, 2009

[Cpp-Programming] Re: doubt in c++

Thank you, thats the info i needed.. and thanks all for your comments .. 

On Thu, Jul 30, 2009 at 11:08 PM, Mohammad-Javad Izadi <m.j.izadi@gmail.com> wrote:

Hi,


They're not the same.


The first one (without the new operator) is static. First of all, this means that it is not dependent on the run-time state of the program. Secondly, the object is created on the stack. This means that in the end of the scope (mostly when the function returns), the object is destroyed (its destructor is called). But with new operator, the object is created on the heap dynamically. In this case the object is not bound to any scope, and therefore, you have to destroy it manually (with delete operator).


The dynamic schema is useful when the creation of an object depends on the run-time state of the program. For example you can have an if-statement, and if the condition holds, create an object, and if it does not, do not create it. This can be done with new, but not with static object creation.


A good example is a dynamic array of objects, i.e. when you do not know in advance how many objects you are going to have.


You can use this code:

    cin >> n;

    Square* sq = new Square[n];


But not with static creation:

    cin >> n;

    Square sq[n];


Here the compiler gives you an error (well, gcc might not give an error, but according to standard c++, it should), because if you create some object statically, it should be clear at compile time, how much space it needs on the memory. Here, the amount of memory needed is dependent on "n" which can't be known until run-time.


I hope this helps!


Regards,

--

MJ


cooldude wrote:

hi,  i'm pretty new to c++. i have got a simple doubt. please answer.  i have a class called square.  class square { //some implementation here }  now when i write the main program i create the object. here is where i'm confused. i feel i can create the object square in two ways. let me know if i'm correct.  square obj_sqr1; // this is one way  square* ptr_square; ptr_square = new square ; //  using the new operator, forgive me if the syntax is wrong  what is the difference between the two ? are they same ? ..     





--
       .     .              
   ...  :``..':        
    : ````.'   :''::'        
  ..:..  :     .'' :
``.    `:    .'     :
   :    :   :        :      
    :   :   :         :
    :    :   :        :  
     :    :   :..''''``::.
      : ...:..'     .''    
      .'   .'  .::::'                    
     :..'''``:::::::      
     '         `::::  
                 `::.        
                  `:: CHEERS!!!
                   :::. ~ VATSA      
        ..:.:.::'`. ::'`.  . : : .
      ..'      `:.: ::   :'       .:  
     .:        .:``:::  :       .: ::
     .:    ..''     :::.'    :':    :
      : .''         .:: : : '
       :          .'`::
                     ::
                     ::
                     ::
                     ::                  
                     ::

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] Re: doubt in c++

On Thu, Jul 30, 2009 at 12:40 PM, Niketa Pal <pal.niketa@gmail.com> wrote:
But I found this site which confused me too:
http://www.codeguru.com/forum/archive/index.php/t-250505.html

Now my question to group is: Is it true dynamic creation is not supported directly by the C++ language."

From the MSDN:

dynamic creation:

The process of creating an object of a specific class at run time. Do not confuse this dynamic creation of an object with the creation of a dynamic object, using the C++ new operator. Dynamic creation is not supported directly by the C++ language. Objects derived from the MFC class CObject can have this functionality.


To be honest, I have no idea what they're talking about.  From what I can gather, the features of CObject in question are Microsoft's homegrown version of RTTI (which they implemented before RTTI was a part of C++).  The MSDN page mentioned in that thread is probably out of date.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] Re: doubt in c++

Good explanation M.J :-)

On Thu, Jul 30, 2009 at 11:08 PM, Mohammad-Javad Izadi <m.j.izadi@gmail.com> wrote:

Hi,


They're not the same.


The first one (without the new operator) is static. First of all, this means that it is not dependent on the run-time state of the program. Secondly, the object is created on the stack. This means that in the end of the scope (mostly when the function returns), the object is destroyed (its destructor is called). But with new operator, the object is created on the heap dynamically. In this case the object is not bound to any scope, and therefore, you have to destroy it manually (with delete operator).


The dynamic schema is useful when the creation of an object depends on the run-time state of the program. For example you can have an if-statement, and if the condition holds, create an object, and if it does not, do not create it. This can be done with new, but not with static object creation.


A good example is a dynamic array of objects, i.e. when you do not know in advance how many objects you are going to have.


You can use this code:

    cin >> n;

    Square* sq = new Square[n];


But not with static creation:

    cin >> n;

    Square sq[n];


Here the compiler gives you an error (well, gcc might not give an error, but according to standard c++, it should), because if you create some object statically, it should be clear at compile time, how much space it needs on the memory. Here, the amount of memory needed is dependent on "n" which can't be known until run-time.


I hope this helps!


Regards,

--

MJ


cooldude wrote:

hi,  i'm pretty new to c++. i have got a simple doubt. please answer.  i have a class called square.  class square { //some implementation here }  now when i write the main program i create the object. here is where i'm confused. i feel i can create the object square in two ways. let me know if i'm correct.  square obj_sqr1; // this is one way  square* ptr_square; ptr_square = new square ; //  using the new operator, forgive me if the syntax is wrong  what is the difference between the two ? are they same ? ..     




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] Re: doubt in c++

Hi,

square obj_sqr1;
- By this way, you can create an object at compile time i.e. when program gets compiled, memory is allocated for obj_sqr1. It's static allocation.

The other way is runtime/dynamic allocation/creation.

But I found this site which confused me too:
http://www.codeguru.com/forum/archive/index.php/t-250505.html

Now my question to group is: Is it true dynamic creation is not supported directly by the C++ language."

Regards,
Niketa

On Thu, Jul 30, 2009 at 9:51 PM, cooldude <srivatsak.s@gmail.com> wrote:

hi,

i'm pretty new to c++. i have got a simple doubt. please answer.

i have a class called square.

class square
{
//some implementation here
}

now when i write the main program i create the object. here is where
i'm confused. i feel i can create the object square in two ways. let
me know if i'm correct.

square obj_sqr1; // this is one way

square* ptr_square;
ptr_square = new square ; //  using the new operator, forgive me if
the syntax is wrong

what is the difference between the two ? are they same ? ..



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] Re: doubt in c++

Hi,


They're not the same.


The first one (without the new operator) is static. First of all, this means that it is not dependent on the run-time state of the program. Secondly, the object is created on the stack. This means that in the end of the scope (mostly when the function returns), the object is destroyed (its destructor is called). But with new operator, the object is created on the heap dynamically. In this case the object is not bound to any scope, and therefore, you have to destroy it manually (with delete operator).


The dynamic schema is useful when the creation of an object depends on the run-time state of the program. For example you can have an if-statement, and if the condition holds, create an object, and if it does not, do not create it. This can be done with new, but not with static object creation.


A good example is a dynamic array of objects, i.e. when you do not know in advance how many objects you are going to have.


You can use this code:

    cin >> n;

    Square* sq = new Square[n];


But not with static creation:

    cin >> n;

    Square sq[n];


Here the compiler gives you an error (well, gcc might not give an error, but according to standard c++, it should), because if you create some object statically, it should be clear at compile time, how much space it needs on the memory. Here, the amount of memory needed is dependent on "n" which can't be known until run-time.


I hope this helps!


Regards,

--

MJ


cooldude wrote:

hi,  i'm pretty new to c++. i have got a simple doubt. please answer.  i have a class called square.  class square { //some implementation here }  now when i write the main program i create the object. here is where i'm confused. i feel i can create the object square in two ways. let me know if i'm correct.  square obj_sqr1; // this is one way  square* ptr_square; ptr_square = new square ; //  using the new operator, forgive me if the syntax is wrong  what is the difference between the two ? are they same ? ..     

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] c++ oracle connectivity on unix

Can anyone help me in the connectivity of c++ with oracle 10g on unix.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] doubt in c++

hi,

i'm pretty new to c++. i have got a simple doubt. please answer.

i have a class called square.

class square
{
//some implementation here
}

now when i write the main program i create the object. here is where
i'm confused. i feel i can create the object square in two ways. let
me know if i'm correct.

square obj_sqr1; // this is one way

square* ptr_square;
ptr_square = new square ; // using the new operator, forgive me if
the syntax is wrong

what is the difference between the two ? are they same ? ..
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

Wednesday, July 29, 2009

[Cpp-Programming] Re: Shapes++, a RAD tool for C++ programming.

On Jul 29, 5:27 pm, BlueRaja <blueraja.ad...@gmail.com> wrote:
> On Wed, Jul 29, 2009 at 5:18 PM, Dos-Man 64 <ChairS...@mail.com> wrote:
> > I'm interested if anyone knows of any similar programs, either for
> > linux or windows.
>
> Uhh... MFC?


I have never learned MFC, nor OWL. Shapes++ spits out "classical" C
code straight out of a Charles Petzold book.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] Re: Shapes++, a RAD tool for C++ programming.

On Wed, Jul 29, 2009 at 5:18 PM, Dos-Man 64 <ChairShot@mail.com> wrote:
I'm interested if anyone knows of any similar programs, either for
linux or windows.

Uhh... MFC?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

[Cpp-Programming] Shapes++, a RAD tool for C++ programming.

Hello, I have created a RAD tool for writing Windows applications in C+
+. The name of the program is Shapes++. It is a completely free
program (no "pro" version), and can be downloaded from www.dos-man.webs.com.

This program generates C++ code for you based on a window that you
design. It even generates subclassing code for controls and tabfocus.
Designing a "simple" window with maybe around 10 controls on it
generates nearly 300 lines of code.

The output code is compatible with MSVC 6. Also working with no
problems using a version of Dev-C. Not all windows versions can run
this. Windows xp hates this program. I have no idea why that is.

I'm interested if anyone knows of any similar programs, either for
linux or windows. I would like to check them out. It seems to me that
there is a lack of simple RAD tools out there to make GUI programming
in C a little easier.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

Thursday, July 16, 2009

[Cpp-Programming] Re: socket file transfer

Take a buffer array and use fget to pick chunk of data from
file .After picking data , copy this data to socket.It will be good if
you create stream sockets.

On Jul 12, 2:08 am, KK <kartikeya.karna...@gmail.com> wrote:
> hello
> can anyone tell me how can i send file from one socket to another
> using c++ in unix.
>
> thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---

Saturday, July 11, 2009

[Cpp-Programming] socket file transfer

hello
can anyone tell me how can i send file from one socket to another
using c++ in unix.

thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to Cpp-Programming@googlegroups.com
To unsubscribe from this group, send email to Cpp-Programming+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Cpp-Programming?hl=en
-~----------~----~----~----~------~----~------~--~---