Solved

c++ beginner (Bbuilder)

Posted on 2000-04-05
2
384 Views
Last Modified: 2012-05-04
Hi, I'm new in c++ Builder and I have following problem
In Delphi I declared public procedures & functions in public part of declarations and then later in code I wrote whole stuff so I'm able to acces these proc & functions form another forms

In builder I found .h files and i added function declaration in public part and then a wrote function in .cpp file but when i try to use my function I'm getting Linker error

example

part of my test_.h file
--------------------------------------

class TForm1 : public TForm
{
__published:      // IDE-managed Components
        TButton *Button1;
        void __fastcall Button1Click(TObject *Sender);
private:      // User declarations
public:            // User declarations
      void  vca (int ulaz);//<------ my declaration
        __fastcall TForm1(TComponent* Owner);
};


and implemenation in test_.cpp
-----------------------------------

void vca(int ulaz) {
//do somthing here (later)
}


& I try to call my function on button click
------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form1->vca(5);
}


When i try to compile program result is:
---------------------------------------------------------------
[Linker Error] Unresolved external 'TForm1::vca(int)' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER4\PROJECTS\TEST_.OBJ.

Or when i try to implement my function as

TForm1::vca(int ulaz)  {
}

error is
[C++ Error] test_.cpp(16): E2316 'TForm1::vca(int)' is not a member of 'TForm1'.


I'm begginer so plese try to give as much detaile's as possible.
Regards Vedran

0
Comment
Question by:xtvca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
DrDelphi earned 20 total points
ID: 2687650
Header://---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:      // IDE-managed Components
    TButton *Button1;
    void __fastcall Button1Click(TObject *Sender);
private:      // User declarations
public:            // User declarations
     void __fastcall DoSomething();
     __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)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DoSomething()
{
  ShowMessage("Dave was here");
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  DoSomething();
}
//---------------------------------------------------------------------------





You'll note that I use __fastcall and that I reference TForm1 when implemtning the function:

void __fastcall TForm1::DoSomething()


Good luck!!



0
 

Author Comment

by:xtvca
ID: 2687866
This was great.
Thanks

You know I posted same question on c++ section but the answer was not at all good as this

Wll look like the Delphi folks rules in quality/support/speed matter.

RegarDs,
Vedran

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question