AKMafia001's Profile User Rating: -----

Reputation: 135 Stalwart
Group:
Active Members
Active Posts:
457 (0.62 per day)
Joined:
11-June 11
Profile Views:
2,933
Last Active:
User is offline Jun 04 2013 10:20 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   AKMafia001 has not set their status

Posts I've Made

  1. In Topic: Why is my variable undefined

    Posted 11 Jan 2013

    You are having a problem with calling the base class constructor...

    Read my this post in your old thread...
  2. In Topic: Why is my variable undefined

    Posted 11 Jan 2013

    The base class constructor accepts some parameters,
    024	    SalariedEmployee(string n, string s, double np, double w, int h, string d);
    
    


    While you didn't pass any in both the cases, either you intended it to call the default constructor or one with empty parameter list which you even didn't declared...
  3. In Topic: Trying to understand this code

    Posted 7 Jan 2013

    If you don't understand the basics of C++, it is really hard to understand this code, as it contains stuff from STL and Win32 API...

    Better learn C++ first...
    Useful C++ links:
    learncpp.com
    cplusplus.com

    Win32 API...

    Hope this Helps!
  4. In Topic: Should I try to work around having to use header files?

    Posted 3 Jan 2013

    You cannot include .cpp files with #include, they should be header files with .h extension(maybe .hpp or .hxx too)...

    But, if you want to use a function from another file, say print.cpp, you can just put a declaration of it in your file(so the compiler would know that this function exists somewhere later) and call it...

    e.g.
    print.cpp
    #include <iostream>
    
    void printHello() {
    	std::cout << "Hello, World!";
    }
    
    


    main.cpp
    void printHello();
    
    int main() {
    	printHello();
    	
    	return 0;
    }
    
    
  5. In Topic: Should I try to work around having to use header files?

    Posted 3 Jan 2013

    In C++, we use '.' operator to select members of an object of some struct or class type. And when that object is a pointer type, '->' is used instead... The case that you didn't find '->' operator in Java is because it doesn't have pointers...

    *this is a hidden pointer inside every class member function which points to the object which called the member function... This is how C++ keeps track of which object is working with the member function...

    The case that we keep class declaration in separate file and its implementation in another, and both of them in different than the main or any other is for the sake of simplicity and reusability... So we can make changes easily to our class and modify it and in future if we need to use the same class in another program then we can easily integrate it into it.

    However, you can have all the stuff in one file, say in main.cpp, you can throw in your class implementation your other code and everything thing else; it will work just fine... But it will be difficult to manage and modify later...

    Even you can have the implementation of the class in the header file too, say in MyClass.h, include it in main file and it will work just fine(but it is not a good programming practice)...

    The rule of thumb is to have the declaration of the class in the header file, its implementation in source file .cpp and include it in your main file...

    Example:
    MyClass.h
    #ifndef MyClass_H
    #define MyClass_H
    
    class MyClass {
    	int data;
    public:
    	int getData();
    	void setData(int);
    	MyClass(int);
    };
    
    #endif
    
    


    MyClass.cpp
    #include "MyClass.h"
    
    MyClass::MyClass(int data)
    	:data(data)
    {
    }
    int MyClass::getData(){
    	return data;
    }
    void MyClass::setData(int data){
    	this->data = data;
    }
    
    


    main.cpp
    #include <iostream>
    #include "MyClass.h"
    
    int main() {
        MyClass myclass(4);
    
        std::cout << myclass.getData() << std::endl;
        myclass.setData(6);
        std::cout << myclass.getData() << std::endl;
    
        return 0;
    }
    
    

    Building from and IDE is simple. But from command line, you have to compile both the files:
    e.g.
    g++ main.cpp myclass.cpp
    



    Coming to your code, you have a conflict with argument lists in your header file and .cpp:
    5	    void setData();
    6	    classType();
    
    


    int data
    04	void classType::setData(int data){
    07	classType::classType(int data)
    
    


    And, Unlike Java, class ends with a semi-colon ; on the closing brace:
    class MyClass {
       ...
    };    // <- semi-colon here
    
    


    PS: What is the linker error you are talking about?

My Information

Member Title:
D.I.C Regular
Age:
22 years old
Birthday:
January 2, 1991
Gender:
Interests:
Computers, Programming, Games, Sports, Cooking, Swimming
Full Name:
Mafia
Years Programming:
6
Programming Languages:
BASIC
C/C++
SQL
Assembly (80x86)
Java
PHP
Javascript
C#

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. Photo

    vaseeprasanna Icon

    18 Dec 2012 - 08:29
    and your rocking
  2. Photo

    vaseeprasanna Icon

    18 Dec 2012 - 08:28
    how to make glass form in c#
  3. Photo

    AKMafia001 Icon

    09 Dec 2012 - 12:04
    You are outstanding, buddy! ;) You have to accept that... :P
  4. Photo

    Xupicor Icon

    09 Dec 2012 - 10:24
    I think you're way overstating my input here at DIC. But still, thanks. :P
  5. Photo

    raghav.naganathan Icon

    09 Dec 2012 - 09:26
    Well, thank you...:)...although its not such a good job compared to what you are doing...:)
  6. Photo

    AKMafia001 Icon

    07 Dec 2012 - 03:15
    Thanks Raghav! You are also doing good job in C/C++...
  7. Photo

    raghav.naganathan Icon

    07 Dec 2012 - 02:56
    Congrats on the excellent answer...and a well deserved 100 :)
  8. Photo

    raghav.naganathan Icon

    05 Dec 2012 - 10:29
    Dude...I have to say this...Outstanding work in the C/C++ forums...:)
    Looks like you are up in line for the expert badge :)
  9. Photo

    techdreamer Icon

    04 Nov 2012 - 06:59
    ok
Page 1 of 1