| |

VerySource

 Forgot password?
 Register
Search
View: 1832|Reply: 13

Very strange question

[Copy link]

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-16 15:20:01
| Show all posts |Read mode
#include <iostream>
using namespace std;
int k = 1;
int main ()
{
int i = 4;
int fun (int);
Ranch
fun (i);
cout << "(1)" << i << ',' << k << endl;
return 0;
}

void fun (int m)
{
m + = k;
k + = m;
{
char k = 'B';
cout << "(2)" << char (k-'A ') << endl;
}
cout << "(3)" << m << ',' << k << endl;
}


This program compiles,
Why does it appear when running:
-------------------- Configuration: Cpp1-Win32 Debug --------------------
Linking ...
Cpp1.obj: error LNK2001: unresolved external symbol "int __cdecl fun (int)" (? Fun @@ YAHH @ Z)
Debug / Cpp1.exe: fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Cpp1.exe-1 error (s), 0 warning (s)


what happened?
Reply

Use magic Report

0

Threads

19

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-1-20 22:36:01
| Show all posts
May be multiple debug windows opened.
Reply

Use magic Report

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-1-21 07:27:01
| Show all posts
Ah? No ...
Reply

Use magic Report

0

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-21 23:09:01
| Show all posts
It may be that the fun function is wrong, change int fun (int); to void fun (int) and try
Reply

Use magic Report

0

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-22 01:27:01
| Show all posts
I made the above modification on my machine and it works fine!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-22 20:27:02
| Show all posts
VC
C ++-> CodeGeneration changed Calling Converation to __cdecl during compilation
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-14 23:15:01
| Show all posts
#include <iostream>
using namespace std;
void fun (int m);
int k = 1;
void main ()
{
int i = 4;


fun (i);
cout << "(1)" << i << ',' << k << endl;

}

void fun (int m)
{
m + = k; // m = 5
k + = m; // k = 6
{
char (k = 'B');
cout << "(2)" << char (k-'A ') << endl;
}
cout << "(3)" << m << ',' << k << endl;
}
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-20 15:30:01
| Show all posts
void fun (int m)
Reply

Use magic Report

0

Threads

15

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-3-25 00:45:01
| Show all posts
This is obviously because the linked interface cannot be found, the claim is inconsistent with the definition
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Invalid IP Address

Post time: 2020-3-25 17:00:01
| Show all posts
No problem on my machine.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list