Jump to content

C++ funkcijas


dobbleextra
 Share

Recommended Posts

Sveiki!

Šodien kodēju un uzskrēju uz problēmas, ar kuru pagaidām netieku galā.

C++ funkcija var izsaukt tikai funkciju, kura ir deklarēta pirms tās, bet ja nu 1. funkcija izsauc 2., bet 2.  noteiktā gādījumā atkal 1.

Vai ir kāds veids kā šo apiet?

Link to comment
Share on other sites

 

 

Vai ir kāds veids kā šo apiet?

Veids kā to apiet ir uzrakstīt funkcijas prototipus pirms tam, kas būtībā notiek ievietojot header failus

Definējot prototipus tu pasaki kompilatoram ka būs tāda funkcija2() un viņš var nokompilēt kodu nezinot ko tieši viņa dara. 

// Funkciju prototipi
void funncija1();
void funkcija2();

void funkcija1()
{
    funkcija2();
}

void funkcija2()
{
    // koautko dara
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...