dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Home » Tip Bank » C++
Language: C
Expertise: Beginner
Oct 4, 2003

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Constructors of Built-in Types

The way we have constructors for user defined data types, we also have constructors for built in data types like chat, int, float and so on. Here is a program that demonstrates this:

#include <iostream.h>

int main()
{
   int i1=int();
   int i2=int(5);
   char c1=char();
   char c2=char('F');
   float f1=float();
   float f2=float(3.29);

   cout<<"int()->"<<i1<<endl;
   cout<<"int(5)->"<<i2<<endl;

   cout<<"char()->"<<c1<<endl;
   cout<<"char('F')->"<<c2<<endl;

   cout<<"float()->"<<f1<<endl;
   cout<<"float(3.29)->"<<f2<<endl;

   return(1);
}

output:-


int()->0
int(5)->5
char()->
char('F')->F
float()->0
float(3.29)->3.29
Rajashekar Narla
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date