I am having trouble understanding the error messages I am receiving when declaring a TObjectList
and a Chord
object in my VCL application for Windows.
I have declared TObjectList<Chord> chordList
and Chord chordObj
both inside and outside of the TForm1
class. Each way generates different error messages.
I have included my header and cpp files below.
Header File:
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <System.Contnrs.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <string>
//---------------------------------------------------------------------------
typedef std::string string;
class Chord {
private:
protected:
public:
string searchKey;
string cKey;
string cRank;
int cFret;
string cPos;
string cPlay;
Chord() {}
Chord(string ck,string cr,int cf,string cp,string csp) {
cKey=ck;
cRank=cr;
cFret=cf;
cPos=cp;
cPlay=csp;
}
};
TObjectList<Chord> chordList;
Chord chordObj;
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
CPP File:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
I am trying to declare a TObjectList
and a Chord
object in my VCL application for Windows, but I am receiving the following error messages:
[bcc32c Error] Unit1.h(38): expected unqualified-id
[bcc32c Error] Unit1.h(39): must use 'class' tag to refer to type 'Chord' in this scope
wingdi.h(3740): class 'Chord' is hidden by a non-type declaration of 'Chord' here
Should I be using TList
versus TObjectList
, or some other version of a List object, given there will be hundreds of Chord
objects in the list? What is the best way of declaring TObjectList
and Chord
in this scenario?