C++
namespace হল
জিনিসপত্র সংগ্রহ করার ড্রয়ার-এর মত । মানসম্পন্ন
লাইব্রেরী গুলো-এর সব আছে এই ড্রয়ারে ।
মানুষের নামের আগে যেমন একটা শব্দ
থাকে MR তেমনি using namespace std এর prefixed হলও ( std:: ).
Using namespace std
এটা
সবার উপরে লেখতে হয় কারন এটা লেখার ফলেই আমি c++ এর মানসম্পন্ন
লাইব্রেরী গুলো ব্যবহার করতে পারবো । এটা না দিলে আমাকে compiler error দেখাবে যখন আমি source code লিখবো
কারন compiler অনেক build in library খুজে
পাবে না তাই using namespace std দিতে হবে ।
Cout,cin,endl এগুলো
সব আছে using namespace std এর মধ্যে ।
#include <iostream>
usingnamespacestd;
int main()
{
cout <<"Hello World";
system("pause");
return0;
}
1.
#include <iostream>
2.
int
main()
3.
{
4.
using namespace std;
5.
cout<<"Hello,
world!\n";
6.
}
OR
Using namespace std
না
দিলেও হবে কিন্তু এটা আমার জন্য অনেক ক্লান্তিকর হবে কারন প্রতিটা স্টেপ এর আগে
আমাকে std::
এই prefix টা
ব্যবহার করতে হবে । কারন std:: এটা হলও c++ এর ড্রয়ার ।যখন আমি std:: দিব
তখন compiler ভাববে যে using namespace std ঘষিত
হোলও ।
1.
#include <iostream>
2.
int
main()
3.
{
4.
std::cout<<"Hello,
world!\n"; //[ std:: ]
5.
}
if you add
using
namespace std; you can write just cout instead of std::cout when calling the operator cout defined in the namespace std
1.
#include <iostream>
2.
int
main()
3.
{
4.
using std::cout;
5.
cout<<"Hello,
world!\n";
6.
}
#include <iostream>
using std::cout;
int main() {
cout << "Hello world!";
return 0;
}
·
using: You
are going to use it
·
namespace: To
use what? A namespace
·
std: The std namespace
(where features of the C++ Standard Library, such as string or vector, are declared).
"using namespace" is a command, and "std" is
a little something called a library. "std" stands for
"standard".
when you write "using namespace std" you are bringing
everything from that library into your class, but it's not quite like using the
"#include" command.
A library is pretty much a big bunch of classes and headers that
can help you in certain areas of your programming.
There are some library's out there that give you many functions
to solve complicated math problems, and there are other library's out there
that might help you to load images or graphics to a computer screen, and there
are many more that can help you with other things.
Although library's are usually downloaded, the "std"
library doesn't need to be downloaded because it comes with the c++ language.
The std library actually contains classes and functions that
help with standard stuff
like: Logging text to a console, making a 'string' variable that can hold unlimited letters, etc.
like: Logging text to a console, making a 'string' variable that can hold unlimited letters, etc.
Now i should probably explain a bit more about the 'using
namespace' command.
Namespace in c++ is a way to put code in a scope, and any code that is outside of that scope cannot see the code inside the namespace.
Namespace in c++ is a way to put code in a scope, and any code that is outside of that scope cannot see the code inside the namespace.
In order for the code that is outside of a namespace to see code
that is INSIDE of a namespace, you must use the "using namespace"
command.
Here is a class that is put inside the namespace scope

0 comments:
Post a Comment