Solved

c++ beginner (Bbuilder)

Posted on 2000-04-05
2
385 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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