Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-04-2005, 12:08 AM   #1 (permalink)
deepak_kr_mehta
banned
 
deepak_kr_mehta's Avatar
 
Join Date: May 2005
Posts: 23
deepak_kr_mehta is on a distinguished road
about wrapper classes and namespace

hello sir
sorry for improper english i am again sending my query

1. what is namespace?what particular purpose std namespace is used?
2. what is wrapper class? please explain with example?
from
deepak kr
deepak_kr_mehta is offline   Reply With Quote
Old 05-04-2005, 12:41 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,705
redhead is on a distinguished road
The std namespace is required, when using cin, cout and endl among others.
When you declare, that you are using a specific namespace, then you maek sure, that your code will use the implementations of those functions as declared in the std namespace.
If you were to combine your code with code from others, then you might end up with an unexpected error, if you're not addressing the namespace required for your part of the code.
An example:
Code:
// the code from others
using err::cout;
using std::cin;
using std:: endl;

int error_function(string error)
{
    cout << error.c_str() << endl;
    return 0;
}

// your code
int my_function(string some_string, string *other_string)
{
    if(some_condition)
    {
        cout << some_string.c_str() << endl;
        other_string = "No user input";
    }
    else
        cin.getline(other_string, '\n');
    return 0;
}
If you're not declaring, that you're using std namespace you will be using the err namespace of cout, which could be whatever the previus coder declared that as, beeing writing to stderr, stdout, a file or whatever.
Now if you in your code, specificaly tells it to be using std namespace you're sure that what ever you parse to cout, will allways end up where the std namespace redirects it, usualy stdout.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 05-04-2005, 05:46 AM   #3 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
You also could take a peek at this thread. Very a amusing thread as well:
return types
__________________
Valmont is offline   Reply With Quote
Old 05-04-2005, 07:55 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Oh what is left is the "wrapper class". Well a wrapper class is basically nothing else but a class to wrap certain (possibly complex) matters into a single class.

Here a few examples:

1).
A C++ programmer encounters a bunch of C code. It may not be optimized for object oriented programming, or it may not be very user friendly. The C++ coder decides to wrap the C code into a C++ class to implement some form of design or user friendlyness.

2).
In large(r) projects, it may be better to wrap compiler, debug, optimization and test stettings into a single class. The programmer is able to use the settings from a central point.
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
abt wrapper class and namespace std deepak_kr_mehta Standard C, C++ 1 05-03-2005 11:53 PM


All times are GMT -8. The time now is 02:57 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting