473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

E2459 VCL style classes must be constructed using operator

62
Hello,
I am working on a program which uses a dynamic array of Employee class objects, the array is defined in EmployeeList class.
When i am calling a function from my form to enter or display Employee object data i'm getting errors:
[C++ Error] E2459 VCL style classes must be constructed using operator new.
(I'm using Borland Builder 6)
This is the code where it points to

Expand|Select|Wrap|Line Numbers
  1. void __fastcall TForm1::CreateEmployeeButtonClick(TObject *Sender)
  2. {
  3.         theEmployeeList.addEmployee(Size);
  4.  
  5.         theEmployeeList.getEmployee(i).create(EnterEmployeeName,
  6.                                              EnterEmployeeSurname,
  7.                                              EnterEmployeeSocialNumber,
  8.                                              EnterEmployeeSalary);
  9. }
  10.  
The function create() is defined in the Employee class:

Expand|Select|Wrap|Line Numbers
  1.  
  2. void Employee :: create(TEdit &EnterEmployeeName,
  3.                         TEdit &EnterEmployeeSurname,
  4.                         TEdit &EnterEmployeeSocialNumber,
  5.                         TEdit &EnterEmployeeSalary)
  6. {
  7.         //initialise data
  8.         FirstName = EnterEmployeeName.Text;
  9.         Surname = EnterEmployeeSurname.Text;
  10.         Salary = StrToFloat(EnterEmployeeSocialNumber.Text);
  11.         SocialNumber = StrToInt(EnterEmployeeSalary.Text);
  12.  
  13. }
  14.  
I was thinking this could do with the dynamic array allocation, tried in many ways but don't get anywhere. This is the way i do it in EmployeeList class:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Employee *myEmployeeList[10];
  3.  
  4.  
  5. void EmployeeList :: addEmployee(&int SIZE)
  6. {
  7.                 myEmployeeList[SIZE]=new Employee();
  8.                 SIZE++;
  9.                 ListSize = SIZE;
  10. }
  11.  
  12.  
  13. Employee EmployeeList :: getEmployee(int index)
  14. {
  15.         return myEmployeeList[index];
  16. }
  17.  
  18.  
  19.  
What am i doing wrong and what does this error mean?
Can't find any info on the web. ;(
Oct 21 '07 #1
5 8963
weaknessforcats
9,208 Expert Mod 8TB
void __fastcall TForm1::CreateEmployeeButtonClick(TObject *Sender)
{
theEmployeeList.addEmployee(Size);

theEmployeeList.getEmployee(i).create(EnterEmploye eName,
EnterEmployeeSurname,
EnterEmployeeSocialNumber,
EnterEmployeeSalary);
}
Visual Component Library (VCL)objects must be created using the new operator and not someting like malloc.

But the code above doesn't jibe with your error since no objects are being created. Worse, the function argument isn't used at all. And even worse, there is some object (theEmployeeList) somewhere and an i and a bunch of other arguments that don't appear to be part of a TForm1 object.

You may need to post more of your code.

BTW: I did a Google on "VCL class" and got 2,520 web pages. Surely there must be info there.
Oct 21 '07 #2
jewel87
62
Visual Component Library (VCL)objects must be created using the new operator and not someting like malloc.

But the code above doesn't jibe with your error since no objects are being created. Worse, the function argument isn't used at all. And even worse, there is some object (theEmployeeList) somewhere and an i and a bunch of other arguments that don't appear to be part of a TForm1 object.

You may need to post more of your code.

BTW: I did a Google on "VCL class" and got 2,520 web pages. Surely there must be info there.
I am using new operator to allocate my array objects, VCL class as i understand are the standart objects in the form, but how can i create them using 'new'? theEmployeeList is an object of EmployeeList class, and the parameter in the function is created automatically when u are working with the forms, i didn't create it. Info on VCL class doesn't help me tosort out this error..
;(
Oct 21 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
Who created the object theEmployeeList ?? You or the VCL library??

If it was you, you need to use the new operator.

and the parameter in the function is created automatically when u are working with the forms, i didn't create it.
I was just noticing that the TObject* argumnet was never used inside the function but a wwhole bunch of other stufff was. I don't know where this other stuff comes from.

You may need to post on VCL forum at Borland to answer this question.
Oct 21 '07 #4
jewel87
62
Who created the object theEmployeeList ?? You or the VCL library??

If it was you, you need to use the new operator.



I was just noticing that the TObject* argumnet was never used inside the function but a wwhole bunch of other stufff was. I don't know where this other stuff comes from.

You may need to post on VCL forum at Borland to answer this question.
Ok, thank you anyway, i'll be trying..
Oct 21 '07 #5
jewel87
62
In case if anyone comes accross same thing, I changed the arguments pass by reference for function create, to passing pointers, this resolved the errors.
Oct 22 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tuure Laurinolli | last post by:
Someone pasted the original version of the following code snippet on #python today. I started investigating why the new-style class didn't work as expected, and found that at least some instances...
0
by: Lefevre | last post by:
Hello I recently had troubles with a class inheritance hierarchy. I solved it, but it didn't satisfied me. I found the solution using this forum :) Actualy i found the following message...
2
by: van | last post by:
Writing classes of some algorithms, some parameters needs to be passed into the classes, the actual algorithms are contained in member functions of classes. What I am thinking is having some...
8
by: Jef Driesen | last post by:
I'm implementing some image processing algorithms in C++. I created a class called 'image' (see declaration below), that will take care of the memory allocations and some basic (mathematical)...
15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
4
by: Kza | last post by:
Hi, just in the process of maintaining some software that used some funy old string library and char*s , and we are updating everything to use std::strings. (or should I say std::basic_string<>s) ...
11
by: aaragon | last post by:
Hi everyone. I'm trying to write a class with policy based design (Alexandrescu's Modern C++ Design). I'm not a programmer but an engineer so this is kind of hard for me. Through the use of...
13
by: JD | last post by:
Hi, My associate has written a copy constructor for a class. Now I need to add an operator = to the class. Is there a way to do it without change her code (copy constructor) at all? Your help...
19
by: C++Liliput | last post by:
I have a custom String class that contains an embedded char* member. The copy constructor, assignment operator etc. are all correctly defined. I need to create a map of my string (say a class...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.