0

In Unit1.h
private:

struct gydytojas {
   int gydid, amzius, specialyb, telefonas, asmkod;
   String vardas[25];
   String pavarde[35];
   String adresas[50]; };
  gydytojas gydmas[100];

Now in Unit1.cpp im trying to do simple thing:

void __fastcall TForm1::Button18Click(TObject *Sender)
{

gydytojas.vardas=Edit21->Text;
gydytojas.pavarde=Edit22->Text;
gydytojas.adresas=Edit24->Text;
}

Getting these errors:
[C++ Error] Unit1.cpp(172): E2108 Improper use of typedef 'TForm1::gydytojas'
Unit1.cpp(170): parsing: void _fastcall TForm1::Button18Click(TObject *)

Any suggestions ?

3
Contributors
6
Replies
8
Views
8 Years
Discussion Span
Last Post by En1ro
1

gydytojas is a struct, but you use it like an object. The problem is the same as if you tried to say int.value = 5; , and the fix is to define a variable of gydytojas to work with. :)

Votes + Comments
Thanks for help ;)
0

gydytojas is a struct, but you use it like an object. The problem is the same as if you tried to say int.value = 5; , and the fix is to define a variable of gydytojas to work with. :)

Oh, so you mean i should define another variable to gydytojas, for example i got : gydytojas gydmas[100]; As if i do so, i get an error:

[C++ Error] Unit1.cpp(169): E2277 Lvalue required
Unit1.cpp(168): parsing: void _fastcall TForm1::Button18Click(TObject *)

And i had changed in struct of gydytojas from String vardas, to AnsiString vardas.

0

Can you please post the code that causes this error? It looks like you're defining the variable wrong or using it wrong.

0

Can you please post the code that causes this error? It looks like you're defining the variable wrong or using it wrong.

void __fastcall TForm1::Button18Click(TObject *Sender)
{
gydmas[1].vardas=Edit21->Text;

This is the code for which that error is generated.

And this code is used in Unit1.h

private:	// User declarations

 

  struct gydytojas {
   int gydid, amzius, specialyb, telefonas, asmkod;
   String vardas[25];
   String pavarde[35];
   String adresas[50]; };
  
   gydytojas gydmas[100];
1

vardas is an array of 25 Strings. So if you want to keep it that way, you need to use
something like: gydmas[1].vardas[[B]some_valid_index_here[/B]] = Edit21->Text;

Votes + Comments
Thanks for help ;)
0

vardas is an array of 25 Strings. So if you want to keep it that way, you need to use
something like: gydmas[1].vardas[[B]some_valid_index_here[/B]] = Edit21->Text;

Thanks, this problem solved :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.