Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °
| |
|
|
You are not logged in.
Post a replyTopic review (newest first)
Yeah, but in first.cpp it declares 'external int' without the 'extern' keyword. But, because of its name, I pressume it also is external.
extern makes available the variable accross all cpp files.
Todays subject: internal and external linkage!
okay, but they don't explain what a 'translation unit' is. Immediatley after it uses the following listings to demonstrate internal and external linkage Code:int externalInt = 5;
const int j = 10;
int main()
{
return 0;
}second.cpp Code:extern int externalInt; int anExternalInt = 10; const int j = 10; after this it says the externalInt variable defined in line 1 of first.cpp has external linkage.
thanks!
& is proper, because you want that function's address.
Not really, however it is fairly rare when they are used. See std::sort for a proper example.
Yes, however this does not mean that the compiler is. A license appears from the start date. So if I start a website in 2000 and keep it running till 2008, I would still put a copyright of 2000 on it.
this is weird... Code:GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.the license is apparently about 17 years old... but I seriously doubt they would put a 1991 compiler on a website still in use today. (or at least as of august 2007)
If you don't know what this means here is a bit of an explanation. The compiler is a program which takes input files (and some addition parameters) and spits out some type of byte-code. Compilers, like any programs, must be run in some form. As with any program, it must be run. Since the compiler typically requires input (namely, code) it must be run from the command line.
they don't have C++ compilers on my schools computers (my school is java biased!)
What compilers are you using? Need name and version numbers.
mm... i think you read my post too fast, Ricky! I said I tried that and it didn't work.
It's just a typo I believe. Code:#include <iostream>
class Dog
{
public:
Dog() {}
~Dog() {}
// method to be pointed to
int bark(long l, double d) { std::cout << "bark " << (l*d) << " times\n"; return 0; }
};
int main()
{
// declare pointer to any dog method that takes a long and a double and returns an int
int (Dog::*p)(long, double);
p = &Dog::bark; // bad???
Dog pokey;
(pokey.*p)(2,4);
return 0;
}
my latest topic: Pointers to functions! Code:#include <iostream>
class Dog
{
public:
Dog() {}
~Dog() {}
// method to be pointed to
int bark(long l, double d) { std::cout << "bark " << (l*d) << " times\n"; return 0; }
};
int main()
{
// declare pointer to any dog method that takes a long and a double and returns an int
int (Dog::*p)(long, double);
p = Dog::bark; // bad???
Dog pokey;
(pokey.*p)(2,4);
return 0;
}according to my book, the statement p = Dog::bark; is how you make p point to that method. On my compiler at home (borland) it compiles and works fine. But today I was using a compiler on a computer in my schools computer lab, and it complained about that statement as being an invalid use of a nonstatic method.
It is an array of 1 dimensional arrays, but in order to be able to create a data structures such as that, you need to define the structure. With an array, you tell the computer "give me an array of size 10". With a (dynamic) matrix, you can't just say "give me a matrix of size 5x4". This is because the memory itself is shaped like an array, but it's not shaped like a matrix. This makes creating arrays more natural than doing so with a matrix.
whoops! i thought i replied to this.
? |