Categories
Uncategorised

Constructors – Person Data

/* Copyright © 2007 Ankur Banerjee. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. http://www.fsf.org/licensing/licenses/lgpl.html /

/ Constructors – Person Data /

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>

int flag = 0;

class address
{
char name[20], street[15], city[20], state[15];
int houseno;
public:
address()
{
houseno = 0;
strcpy(name, ”);
strcpy(street, ”);
strcpy(city, ”);
strcpy(state, ”);
}
address(int num, char n[20], char st[15])
{
houseno = num;
strcpy(name, n);
strcpy(street, st);
strcpy(city, “Delhi”);
strcpy(state, “India”);
}
void disp(char n[20])
{
if (strcmp(n, name) == 0)
{
cout<<endl<<“Name : “<<name<<endl
<<“House number : “<<houseno<<endl
<<“Street : “<<street<<endl
<<“City : “<<city<<endl
<<“State : “<<state<<endl;
flag = 1;
}
}
} ;

void main()
{
clrscr();
int h;
char n[20], st[15];
cout<<endl<<“Enter house number : “;
cin>>h;
cout<<“Enter name : “;
gets(n);
cout<<“Enter street : “;
gets(st);
address ad (h, n, st);
cout<<“Enter the same name again : “;
gets(n);
ad.disp(n);
if (flag == 0)
cout<<endl<<“Moron, I said enter the SAME name!”<<endl;
getch();
}

/ Output */

Enter house number : 42
Enter name : Arthur Dent
Enter street : 42, Guide Road
Enter the same name again : Arthur Dent

Name : Arthur Dent
House number : 42
Street : 42, Guide Road
City : Delhi
State : India

Categories
Uncategorised

Free C++ Compilers

Many of my friends have asked me at times about where they can download the Jurassic-era C++ compiler they use at school, namely Turbo C++. You won’t get the latest version, and surprisingly, many DON’T want the latest compilers. So here’s a roundup of some of the free C++ compilers around. Note that these are free as in beer, but may not necessarily be free as in speech.

  • Turbo C++: I really don’t know what Indian schools found so good about this. Maybe it’s all the fault of that woman Sumita Arora whose books (unfortunately) continue to be used in Indian schools. Oh never mind. The latest in their line are not free; however, the developers, Borland, have decided to give Turbo C++ v1.01 away for everyone on their CodeGear Developer Network. You can read this article on CG DN, where they feel so smug about giving something useless away for free, and they’ve the cheek to put in a section called ‘Antique Software’. The direct download link is this, but if it doesn’t work, click on the article link I gave earlier. Update: My friend Abhishek has given a download link for Turbo C++ 3.0. This is an even newer version that you may want to try out.
  • Dev C++: My fave compiler of choice on Windows systems, this one is made by Bloodshed Software. Here’s the Dev C++ page. No no, there’s nothing gory about it. What I hate the most about it? Can’t handle spaces in installation folder paths.
  • Microsucks Visual C++: Who wants this anyway? If you still do, then head here. Visual C++ Express Edition is their free version. They’ve multiple versions, but I’d suggest you stick to Basic for school needs.
  • Intel C++: It isn’t free for Windows users, you can get only a trial version, but if you’re a Linux user, which in DPS Vasant Kunj translates to ‘1. Ankur Banerjee 2. None’, then you can use the Intel C++ Compiler for Linux for free. BUT, it’s a real heavy download, and more for the professional coder, not for school use.

A bit on C++ on Linux. Linux has got THE BEST support for programming, as far as current standards go. If you wanna do some good coding according to ANSI / ISO standards, then switch to Linux. GCC is real good, and updated quickly. Mostly, on Linux, code can be written on any text editor, and don’t roll your eyes because the Linux equivalents of Microsucks Notepad are far more advanced, offering spell check, word completion, highlighting in 2-3 dozen different language styles etc. In fact, some even come with built in console options to test your programs. And then, when li’l baby programmer wants to grow up, then you can start using something like Anjuta or Qt.