Friday, March 25, 2011

namespace - error: 'vector' has not been declared, 'cout' was not declared in this scope

If you are newbie in programming cpp programs and trying out simple 'cout', 'endl' operations or trying out your hands on vectors etc. And you found some same error patterns given below.

isoStandardC.cpp:73: error: ‘cout’ was not declared in this scope
isoStandardC.cpp:73: error: ‘endl’ was not declared in this scope
isoStandardC.cpp:76: error: ‘cout’ was not declared in this scope
isoStandardC.cpp:76: error: ‘endl’ was not declared in this scope
isoStandardC.cpp:77: error: ‘ifstream’ was not declared in this scope

isoStandardC.cpp:25: error: ‘vector’ has not been declared
isoStandardC.cpp:25: error: expected ‘,’ or ‘...’ before ‘<’ token
isoStandardC.cpp: In function ‘int main(int, char**)’:
isoStandardC.cpp:118: error: cannot convert ‘std::vector >, std::allocator > > >’ to ‘int’ for argument ‘2’ to ‘void binString(int, int)’

Then you missed putting 'namespace' in the starting of the program. Confused???

Why we need to use namespace std in cpp??

C++ provides one global namespace. Namespaces allow to group entities like classes, objects and functions under a name. The basic structure for defining a custom 'namespace' is given below:

namespace myNameSpace
{
int x, y;
}

you can access the integer variable using scope operator :: 

myNameSpace::x
myNameSpace::y

So, now the solution for the above error message, you need to use this at the top of the line program
or header file

using namespace std;

It tells the compiler to treat the names in the standard library, a very important part of the C++ language definition.

you can also be specific to vectors: using namespace std::vector
 

Even you don't "have to" use "using namespace std;" in C++. It just makes typing easier. Here are two identical programs, one with, and one without.

#include
using namespace std;
int main () {
cout << "Hello World of C++ programming!" << endl;
return 0;
}

#include

int main () {
std::cout << "Hello World of C++ programming!" << std::endl;
return 0;
}


For more  detail you can refer: LINK1, LINK2, LINK3

Tuesday, March 15, 2011

Auto Indent, Comment And Uncomment Code in Visual Studio (VC++)

I found some nice shortcuts for Auto Indenting, commenting and uncommenting my codes in Visual Studio. I want to share it with the world.

Auto Indent: Select the piece of the code you want to comment or all (CTRL + a) ;)

1st Trick: "CTRL + F8" (Boom, Indented in one shot :D )

2nd Trick: Press "CTRL + k" then followed by "CTRL + F" (Two Step Indenting but it works)
(PRESS "CTRL + k" Press "CTRL + F")

Auto Comment: Again the same, Select the piece of the code or all (CTRL + a) ;)

First Press "CTRL+k" then press "CTRL+c" (Press "CTRL + k" Press"CTRL+c")

Auto Uncomment: Select the Piece of the code you want to uncomment or all (CTRL + a) ;)

First Press "CTRL+k" then press "CTRL+u" (Press "CTRL + k" Press"CTRL+u")

And one good link for shortcut Poster (Cheat Sheet) given in MSDN Blog (CLICK ME).

Saturday, March 5, 2011

End of Lease Contract in Germany (Hause Vertrag) – Points to take care of

As there are often problems at the end of a lease contract with the landlord (alleged damages, renovation demands, and deposit refund) here are the important points to heed:

1. If you want to terminate the lease, the termination notice must be in written form. An oral or notice via email is not valid.

2. Document the state of the flat at the time of returning with photos

3. If there is a formal handover procedure, do not do it alone, especially if the landlord is accompanied by witnesses (housemaster, etc.).

4. Oftentimes, the landlord issues a formal handover protocol. Be careful as to its content. Do not sign it if the landlord includes descriptions and obligations which you do not understand and with which you disagree. At least make sure to add before signing the following caveat: “Unter ausdrücklichem Widerspruch und ohne Anerkenntnis einer Rechtspflicht“.

5. With regard to the deposit refund: Prepare a letter which states that you seek back the deposit as soon as possible to be wired to your following account xy. If you do not want to divulge your bank account data, you can explicitly name a third person with full address and account details who is your confidant and state in the letter that the deposit should be paid back to this person. Also, state your email address and state that any further correspondence should be sent to this email address. Have this letter signed by the landlord and make a copy.

6. If on the day of hand over, the landlord is unwilling to accept the keys because he wants you to do work or clean up in the apartment, which you refuse to do, do not keep the keys but insist he take them back. Even if you are willing to do the desired work, first formally hand over the keys and ask for the landlord to provide access to flat on a given day. Retaining the keys could subject you to further payment claims.

These are some points to take care of at the end of a lease.

Likewise, when first renting an accommodation make sure you do not sign a hand over protocol which states that the apartment is in a flawless condition. You can never be 100% sure it is. Also, avoid highlighting some visible defects as an exception. This is even more dangerous. When a dispute arises later, it will be argued that not mentioned defects have been caused by you as a tenant. On the subject of defects: If any irregularity occurs, do not keep silent and ignore it. Instead, inform the landlord immediately of this irregularity in written form.

Source community email by kanzlei-jain.de