Click here to Skip to main content
15,908,013 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Read lines in a file Pin
Christian Graus4-Jul-07 11:01
protectorChristian Graus4-Jul-07 11:01 
QuestionTrivial Property not working Pin
iddqd5153-Jul-07 11:13
iddqd5153-Jul-07 11:13 
QuestionRe: Trivial Property not working Pin
Mark Salsbery3-Jul-07 11:57
Mark Salsbery3-Jul-07 11:57 
AnswerRe: Trivial Property not working [modified] Pin
iddqd5153-Jul-07 12:13
iddqd5153-Jul-07 12:13 
GeneralRe: Trivial Property not working Pin
Mark Salsbery3-Jul-07 12:36
Mark Salsbery3-Jul-07 12:36 
GeneralRe: Trivial Property not working Pin
iddqd5155-Jul-07 5:08
iddqd5155-Jul-07 5:08 
GeneralRe: Trivial Property not working Pin
Mark Salsbery5-Jul-07 6:07
Mark Salsbery5-Jul-07 6:07 
AnswerRe: Trivial Property not working Pin
iddqd5153-Jul-07 12:16
iddqd5153-Jul-07 12:16 
Here's my other test case that is confusing the hell out of me. The errors/results/questions are all in the comments:

#include "stdafx.h"

using namespace System;

// managed class with explicity copy constructor and assignment operator
ref class Foo
{
public:
   Foo() {} // default constructor

   // constructor takes a single parameter
   // intialize value data member via direct access or through property
   Foo(int d)
   {
      Value = d; // (3)
      //value = d; // (4)
   }
   // copy constructor
   // could declare parameter const but then you can't use Value property
   Foo(Foo^ b) //: value(b->value) Initializer presumably doesn't work for the same reasons
   {
      //Value = b->Value; // (1)
      value = b->value; // (2)
      //value = b->Value; // Presumably doesn't work for the same reasons
   }

   // trivial property declaration, in theory creates the same code as the explicit below
   property int Value;

   // explicit property declaration
   /*property int Value
   {
      int get()
      {
         return value;
      }
      void set(int v)
      {
         value = v;
      }
   }*/

// note: value must be public for Block B to work.
// Public or private doesn't affect the following results.

//private:
   int value;
};


int main (array<System::String ^> ^)
{
    // **************************************************************************
    // The following results are based on using the default constructor
    // and setting the value member after construction
    // Define 'works' to mean the copy constructor properly initializes the
    // value data member of the new Foo object to be equal to the value in the passed argument
    /* If the copy constructor uses (1) instead of (2):
     * TRIVIAL PROPERTY DECLARED: Block A works, Block B doesn't work
     * EXPLICIT PROPERTY DECLARED: Block A works, Block B works

     * If the copy constructor uses (2) instead of (1):
     * TRIVIAL PROPERTY DECLARED: Block A doesn't work, Block B works
     * EXPLICIT PROPERTY DECLARED: Block A works, Block B works
     *****************************************************************************/

   // *****************************************************************************
   // The following results are based on using the single parameter constructor
   // to set the value data member
   /* If the single parameter constructor uses (4) instead of (3):
    * TRIVIAL PROPERTY DECLARED: Block A doesn't work, Block B works
    *    The single parameter constructor doesn't properly assign value
    *    Copy constructor may not be working either
    * EXPLICIT PROPERTY DECLARED: Block A works, Block B works
    
    * If the single parameter constructor uses (3) instead of (4):
    * TRIVIAL PROPERTY DECLARED: Block A doesn't work, Block B doesn't work
          Block A the single parameter constructor works but the copy constructor doesn't
          Block B the single parameter constructor doesn't work and the copy constructor may not either
    * EXPLICIT PROPERTY DECLARED: Block A works, Block B works
    ********************************************************************************/

   // Block A
   //Foo b(5); // uncomment this line and comment out the next 2 for the second set of results
   Foo b;
   b.Value = 5;
   Foo^ c = gcnew Foo(%b);

   Console::WriteLine("After creating c using the copy constructor passing b:");
   Console::WriteLine("b.Value: " + b.Value + " c->Value: " + c->Value);
   c->Value = 10;
   Console::WriteLine("\nAfter updating c->Value via property:");
   Console::WriteLine("b.Value: " + b.Value + " c->Value: " + c->Value);

   Console::WriteLine();

   // Block B
   //Foo d(5); // uncomment this line and comment out the next 2 for the second set of results
   Foo d;
   d.value = 5;
   Foo^ e = gcnew Foo(%d);

   Console::WriteLine("\nAfter creating e using the copy constructor passing d:");
   Console::WriteLine("d.Value: " + d.value + " e->Value: " + e->value);
   e->value = 10;
   Console::WriteLine("\nAfter updating e->Value via property:");
   Console::WriteLine("d.Value: " + d.value + " e->Value: " + e->value);
}

GeneralRe: Trivial Property not working Pin
Daniel Grunwald10-Jul-07 8:42
Daniel Grunwald10-Jul-07 8:42 
GeneralRe: Trivial Property not working Pin
iddqd51510-Jul-07 11:11
iddqd51510-Jul-07 11:11 
QuestionTo refresh Data in my DataGridView Pin
mikobi3-Jul-07 5:11
mikobi3-Jul-07 5:11 
AnswerRe: To refresh Data in my DataGridView Pin
Paul Conrad14-Jul-07 13:39
professionalPaul Conrad14-Jul-07 13:39 
Questiondynamic cast question Pin
Programm3r3-Jul-07 4:27
Programm3r3-Jul-07 4:27 
AnswerRe: dynamic cast question Pin
George L. Jackson3-Jul-07 10:53
George L. Jackson3-Jul-07 10:53 
GeneralRe: dynamic cast question Pin
Programm3r3-Jul-07 19:54
Programm3r3-Jul-07 19:54 
QuestionWinPcap C++ CLI Pin
abbd3-Jul-07 4:01
abbd3-Jul-07 4:01 
QuestionHelp Needed Fast Pin
A. K. S3-Jul-07 1:43
A. K. S3-Jul-07 1:43 
AnswerRe: Help Needed Fast Pin
Pete O'Hanlon3-Jul-07 1:53
mvePete O'Hanlon3-Jul-07 1:53 
Questionsrand in c or c++ doesn't really Generate Random Numbers ? Pin
snailflying2-Jul-07 21:45
snailflying2-Jul-07 21:45 
AnswerRe: srand in c or c++ doesn't really Generate Random Numbers ? Pin
Pete O'Hanlon3-Jul-07 1:57
mvePete O'Hanlon3-Jul-07 1:57 
GeneralRe: srand in c or c++ doesn't really Generate Random Numbers ? Pin
snailflying3-Jul-07 15:53
snailflying3-Jul-07 15:53 
QuestionInterior Pointer vs Handle Pin
iddqd5152-Jul-07 4:37
iddqd5152-Jul-07 4:37 
AnswerRe: Interior Pointer vs Handle Pin
led mike2-Jul-07 5:07
led mike2-Jul-07 5:07 
GeneralRe: Interior Pointer vs Handle Pin
iddqd5152-Jul-07 5:25
iddqd5152-Jul-07 5:25 
GeneralRe: Interior Pointer vs Handle Pin
George L. Jackson2-Jul-07 14:23
George L. Jackson2-Jul-07 14:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.