tags:

views:

448

answers:

1

Hi i am creating a Datatable in C++ as follows
when i try to create the instance i am getting a compile time error as cannot creating instance for abstract class. here i am not usng any abstract keyword.

#include "stdio.h"
#include "conio.h"
#using <mscorlib.dll>
using namespace System::Data;
using namespace System::ComponentModel;
using namespace System;

[Serializable]
 public __gc class Table :public MarshalByValueComponent,public IListSource,public ISupportInitialize,public System::Runtime::Serialization::  ISerializable

{
public:
    void MakeTable();
void main()
  {  
    Table *s=new Table();
    s->MakeTable();
    Console::WriteLine("Hai");
    printf("hello");
    getch();
  }
};
 void Table::MakeTable()
 {

     DataSet* myDataSet;
    // Create a new DataTable.
    DataTable* myDataTable = new DataTable(S"ParentTable");
    // Declare variables for DataColumn and DataRow objects.
    DataColumn* myDataColumn;
    DataRow* myDataRow;

    // Create new DataColumn, set DataType, ColumnName and add to DataTable.    
    myDataColumn = new DataColumn();
    myDataColumn->DataType = System::Type::GetType(S"System.Int32");
    myDataColumn->ColumnName = S"id";
    myDataColumn->ReadOnly = true;
    myDataColumn->Unique = true;
    // Add the Column to the DataColumnCollection.
    myDataTable->Columns->Add(myDataColumn);

    // Create second column.
    myDataColumn = new DataColumn();
    myDataColumn->DataType = System::Type::GetType(S"System.String");
    myDataColumn->ColumnName = S"ParentItem";
    myDataColumn->AutoIncrement = false;
    myDataColumn->Caption = S"ParentItem";
    myDataColumn->ReadOnly = false;
    myDataColumn->Unique = false;
    // Add the column to the table.
    myDataTable->Columns->Add(myDataColumn);

    // Make the ID column the primary key column.
    DataColumn* PrimaryKeyColumns[] = new DataColumn*[1];
    PrimaryKeyColumns->Item[0] = myDataTable->Columns->Item[S"id"];
    myDataTable->PrimaryKey = PrimaryKeyColumns;

    // Instantiate the DataSet variable.
    myDataSet = new DataSet();
    // Add the new DataTable to the DataSet.
    myDataSet->Tables->Add(myDataTable);

    // Create three new DataRow objects and add them to the DataTable
    for (int i = 0; i<= 2; i++){
       myDataRow = myDataTable->NewRow();
       myDataRow->Item[S"id"] = __box(i);
       myDataRow->Item[S"ParentItem"] = String::Format( S"ParentItem {0}", __box(i));
       myDataTable->Rows->Add(myDataRow);
    }
A: 

You probably didn't implement members in your interfaces (IListSource requires GetList method) and therefore your class is abstract until you implement (or subclass and then implement) the missing methods.

Dani