Visual C++ :: Include Object From Another ATL COM DLL - Employee Classes?

Nov 7, 2014

This refers to an ATL COM DLL project. I can successfully create a class hierarchy of objects, ie. say, one class is the TEAM, which then holds other objects, say, a leader and a secretary, both of which are Employee Classes . Here goes my question:

a) In the Team.h header file I declare m_pLeader as a CComPtr<IEmployee>

Code:
classATL_NO_VTABLE CTeam :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CTeam, &CLSID_Team>,
public IDispatchImpl<ITeam, &IID_ITeam, &LIBID_BUOBJ05Lib, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
private:
CComPtr<IEmployee> m_pLeader;
CComPtr<IEmployee> m_pSecretary;

b) The Employee Class is defined within this ATL COM project.
c) In the Team.cpp file, I create an instance in the FinalConstruct code, the focus is on the CEmployee

Code:
HRESULT CTeam::FinalConstruct(){
CComObject<CEmployee>* pLeader;
HRESULT hr=CComObject<CEmployee>::CreateInstance(&pLeader);
if (FAILED(hr))
return hr;
m_pLeader=pLeader;
// ..same for secretary...
return S_OK
}

d) Here comes my QUESTION: How must I proceed if the Employee object was part of another ATL COM DLL, that is it would be described in another DLL that I would now like to reuse? I guess I need to

1. Have the other DLL's idl-, tlb, and h file in my project folder. Let me name it "other.h, other.idl, other.tlb"

2. Both h- and cpp-file must have an #include "other.h" statement -- please correct if I am wrong..

3. ...but how must in the Team's h- and cpp-files the statements be (assuming the class in the "other" Dll is Member (instead of Employee? I know the following code will NOT work, so I am asking how it should be correctly?

Code:
private:
CComPtr<IMember> m_pLeader;

4. and in cpp file for:

Code:
CComObject<CMember>* pLeader;
HRESULT hr=CComObject<CMember>::CreateInstance(&pLeader);
[/code]

View 10 Replies


ADVERTISEMENT

C# :: How To Autogenerate Employee Id When User Enters Details Of Employee

Jul 4, 2013

I want to autogenerate employee id when user enters details of employee

Conditions:

User Selects Department which should be used as prefix.

A new Sequence of numbers must be generated for each department

Example:
DeptA0001
DeptA0002
Again DeptB new seuquence must be started
DeptB0001
DeptB0002...

View 3 Replies View Related

Visual C++ :: Employee Payroll Program Using Structures Does Not Show All Data

Dec 11, 2013

I am writing a employee payroll program using structures. My program is running but its only showing some of the data.

HERES MY CODE

Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
#include <cstring>
using namespace std;
const int SZ = 20; // size of arrays to hold scores
struct payrollStruct {

[Code] ....

And it doesn't show anything from txt file

Code:
40.0 10.00 A1234 Jane Adams
50.0 10.00 L8765 Mary Lincoln
25.5 10.85 W7654 Martha Washington
52.0 15.75 A9876 John Adams
45.0 25.00 W1235 George Washington

[Code] .....

View 14 Replies View Related

Visual C++ :: Employee Class - Number Of Vacation / Sick Days Used

Oct 21, 2012

Can not even say this is the error as it is giving me 45 errors. l am writing code which accept employee type based on calculating the miles traveled in a year,my code is based on type of employee, number of vacation days used and no of sick days used.

#include <iostream>
#include <iomanip>
#include <conio.h>
class employee {
int emp_type;
float emp_vacation;

[Code] ....

View 11 Replies View Related

Visual C++ :: Additional Include And Library Directories

Nov 19, 2012

For each project in a VS solution it's possible to stipulate per-project folders that get searched in addition to the folders that you've set globally for Visual Studio.

Which folders take priority? Do the project's folders get searched first? Or do the global folder get searched first? Or is it possible to select one set as having priority over the other?

(this is VS 2005 BTW)

View 4 Replies View Related

Visual C++ :: How To Configure Additional Include Headers

Jun 16, 2014

I want to include boost directory. What must be in the Additional Include Directories input?

I tried

C:C++boost_1_55_0libsaccumulatorsexample;$(BOOST_ROOT);%(AdditionalIncludeDirectories)

But I am still getting error "Cannot open include file: 'boost/libs/accumulators/lambda/lambda.hpp': No such file or directory" when I include

Code:
#include <boost/libs/accumulators/lambda/lambda.hpp>

The file is placed out side of boost directory of sure.

View 3 Replies View Related

Visual C++ :: Employee Payroll - Read Data From Text File And Sort

Nov 11, 2013

i tring to write a employee payroll code with functions and read data from the txt. file and also bubble sort that sorts and displays starting from employees last name and calculations.

//txt file//
Hours Pay rate empID first name last name
40.0 10.00 A1234 Jane Adams
50.0 10.00 L8765 Mary Lincoln
25.5 10.85 W7654 Martha Washington
52.0 15.75 A9876 John Adams
45.0 25.00 W1235 George Washington
40.25 55.00 L9087 Abraham Lincoln
30.0 9.75 T9876 William Tell
42.5 12.50 M7654 Missy Muffett
30.0 10.00 P8765 Peter Piper

and here is my code

Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;
void tellUser();

[Code] .....

here are the errors the are giving

Code:
payroll.cpp: In function "int bubbleSort()":
payroll.cpp:52:8: error: "lastpos" was not declared in this scope
payroll.cpp:52:18: error: "numemp" was not declared in this scope
payroll.cpp:56:10: error: "swapmade" was not declared in this scope
payroll.cpp:57:16: error: "i" was not declared in this scope

[Code] ....

View 14 Replies View Related

C++ :: Cast Directly Between Base Classes Of Object?

Jul 1, 2013

I've got two classes, which are both derived from the same two base classes. Here's a representation of the actual code:

Code: #include <vector>
class BaseClassA {
};
class BaseClassB {
};
class TestClassX
: public BaseClassA,
public BaseClassB

[code].....

Basically, I'd like to know if it is possible to cast directly from a BaseClassA pointer to a BaseClassB pointer, without casting to the child class first.

View 10 Replies View Related

C/C++ :: Unexpected Behavior For Classes That Contain Member Object

Apr 1, 2014

I have a WordRecord that contains a LinkedList (both my doing). I have rigorously tested my LinkedList class, and know that it works (heck, I used it in the last project I had!). The problem is that undefined behaviour seems to happen when using the WordRecord, which has a std::string and a LinkedList<unsigned>. (The problem happens with the LinkedList.)

Here is the code:

main.cpp
#include <iostream>
#include "BinaryTreeNode.h" // here for test purposes
#include "LexicographicTree.h"
#include "LinkedList.h"//also for test purposes
#include "OutputStream.h"
#include "WordRecord.h"
using namespace std;
int main()
{
// setup the OutputStream to print to "test.txt"
OutputStream stream("test.txt");
// create a sampleWordRecord (make it have the word "I" on line 1)

[code]....

One of the requirements for the project is that it must compile on Unix server (I am using Windows, and have tested it in both environments.) I get a core-dump in the Unix environment. On the other hand, the output on-screen in the Windows environment looks right. However, when I open up the text file, I get the following

Sample word record:

WordLines
I{14}
/* I have no what is happening to sampleWordRecord's LinkedList; I am not trying to modify it, except for where I created the sampleWordRecord! */

View 14 Replies View Related

Visual C++ :: Include Library Paths In VS 2012 Through The New Property Pages?

Jan 30, 2013

I am trying to include library paths in VS 2012 through the new property pages.I downloaded and installed mpich2-64 bit libraries under "C:Program FilesMPICH2include" and set the include path in Microsoft.cpp.x64.user property file so the path now looks like

Code:
"$(VCInstallDir)include;$(VCInstallDir)atlmfcinclude;$(WindowsSDK_IncludePath);C:Program FilesMPICH2include;"

But somehow it fails to find the files.

Code:

fatal error C1083: Cannot open include file: 'mpi.h': No such file or directory

The file is definitely there, so what could be the problem ?

View 1 Replies View Related

Visual C++ :: Calculate Amount Paid To Employee Based On Hours Worked And Rate Per Hour

Oct 8, 2013

Write a program in C++ that calculates the amount to be paid to an employee based on the hours worked and rate per hour. A user will enter hours worked and rate per hour for an employee. Your program should have a function payCheck that calculates and returns the amount to be paid. The formula for calculating the salary amount is as follows: for the first 40 hours, the rate is the given rate (the rate that a user has entered); for hours over 40, the rate is 1.5 times the given rate.

I had write my own coding, but it keeps error. it is okay. But i still don't think i could share here? Still running... I will update my coding for you alls to check for any syntax or logic error. The problem is i need to calculate if the employee work for more than 40 hours which 1.5 times.

Code:
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <iostream.h>
using namespace std;
int main(void) {
char *empname, *test, *final_output;

[Code] .....

View 7 Replies View Related

C++ :: Object And Classes - Declaration Of Variable Using User Defined Type

Mar 17, 2013

I am getting a compilation error from the code below. It is when i am naming a variable with my user defined type.

#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
class person {

[Code] .....

C:Dev-CppTRIAL.PASS.!!!.cpp In function `int main()':
66 C:Dev-CppTRIAL.PASS.!!!.cpp expected primary-expression before "p"
66 C:Dev-CppTRIAL.PASS.!!!.cpp expected `;' before "p"
74 C:Dev-CppTRIAL.PASS.!!!.cpp `p' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
83 C:Dev-CppTRIAL.PASS.!!!.cpp `X' undeclared (first use this function)

View 4 Replies View Related

C++ :: Nested Classes - How Members Be Accessed Through Object Of Enclosing Class Type

May 18, 2013

"A nested class has free access to all the static members of the enclosing class. All the instance members can be accessed through an object of the enclosing class type, or a pointer or reference to an object."

How can the members be accessed through an object of the enclosing class type? I understand the pointer and reference part because for them you dont need the full definition, but for creating a object you do?

Also it has free access to all static members because the nested class is part of the enclosed class and with static it exists in everything inside the enclosing class? Right or am I missing something?

View 4 Replies View Related

Visual C++ :: Implementing Classes And Creating Driver Function?

Nov 30, 2012

I'm am having a few issues with this program, they stem from passing the color.h and .cpp into another .h and .cpp, and frankly getting how those two things really fit together.

For this problem, you will design and implement 2 classes and then write a driver function to test these classes. The first will be a C++ class for an abstract data type color with a public enumeration type colorType that has the color values shown in Listing 10.8. Your abstract data type should have an attribute for storing a single value of type colortype and member functions for reading (readColor) and writing (writeColor) a color value as well as setting and accessing it. The function readColor should read a color as a string and store the corresponding color value in the value attribute of a type color object. The function writeColor should display as a string the value stored in the value attribute of a type color object (see Figure 7.5). Modify class circle and the driver function in Listing 10.9 to include and use this class. You'll need to remove the declaration for color in class circle. Test your modified driver function with the new color and circle classes.

The second class will be to design and implement a rectangle class similar to class circle. Be sure to incorporate the new color class you have written and tested in the first part of the programming exercise. Write a client program that asks the user to enter a shape name (circle or rectangle) and then asks the user for the necessary data for an object of that class. The program should create the object and display all its attributes.

The circle class .h and .cpp files as well as the original driver function will be supplied. You are to provide the .h and .cpp files for the new color class and the modified driver function as well as the .h and .cpp files for the rectangle class and the client program that uses all three classes.

color.h

Code:

//color.h
//Color class definition
#include "stdafx.h"
#ifndef COLOR_H

[Code].....

View 3 Replies View Related

Visual C++ :: Friend Classes In Separate Header Files?

Nov 25, 2012

I am struggling to enable friendship between two classes in separate header files for a banking program.

I am attempting to get the Person class to use variables from the Account class. Heres what I have so far.

ACCOUNT.h:

Code:
#include<iostream>
#include<fstream>
#include<cctype>
#include<iomanip>
#include <string>
#include <math.h>
#include <windows.h>
#include <vector>
#include "Person.h"
using namespace std;
class person;

[code].....

View 3 Replies View Related

Visual C++ :: Destroying CArray Of Cobject Derived Classes

Nov 21, 2013

I use a CArray<CClase1,CClase1> m_Clases1.

CClase1 is derived of CObject. " class CClase1 : public CObject"

When, at last I do : "m_Clases1.RemoveAll()" , I suppose that the CClase1 destructor is called. But when i do this the program fails.

View 6 Replies View Related

Visual C++ :: Vendor Classes - Conflicting Declaration Of Objects

Jan 22, 2013

The Light and Fan are two different vendor classes and they are not derived from any base class. I am trying to implement the Command design pattern but with generic implementation, so it should work in future with any new vendor class like Door, Window etc without much change in client code. I have thought about a Factory method but it will not work because it needs a Base class. I am trying to learn the design patterns.

Light *myobj;
Fan *myobj;
int choice;
cout<<"Select Light (1): ";
cout<<"Select Fan (2): ";

[Code] ....

Error:conflicting declaration 'Fan*myobj'

View 14 Replies View Related

C++ :: Array Of Classes With Classes Inside

Oct 5, 2013

I have an array of (Student)classes created in Manager.h, which contains a new instance of class Name (name),(in Student.h)How would I go about accessing the SetFirstName method in Name.cpp if I was in a class Manager.cpp? I have tried using Students[i].name.SetFirstName("name");

// In Manager.h
#include"Student.h"
class Manager
{

[Code]....

View 2 Replies View Related

C :: 6 Structure Array For Employee Pay

Jul 23, 2013

Ok, so this assignment is to create a structure that allows input for up to 6 employees that then makes a 6 structure array showing Employee ID, Employee Last Name, Employee Pay Rate, Employee Hours Worked, Employee Pay, and Total Gross Pay for All Employees.

I don't have a printf yet for total gross, but right now I am just trying to tackle the input. Obviously I am not doing it right because although gcc complier is not giving errors the program is not ending when I type 'q' (sentinel issue) or when I reach 6 employees. It just continues input forever. Here is my code so far:

Code:
//Cameron Taylor
#include <stdio.h>
#define MAXARRAY 6
struct Record{
int idnum;
char lname[20];
double pay_rate;

[Code] ........

View 9 Replies View Related

C/C++ :: Enter And Store Employee Objects

May 17, 2014

Okay, I'm not entirely certain where my code is messed up, but when I run the console it asks if I want to add Employee information and then it just skips through everything when I say yes.

#include <iostream>
#include <iomanip>
#include <string>

[Code].....

View 14 Replies View Related

Visual C++ :: How To Clone Object

Jul 24, 2014

I define two classes in C++, as follows:

class CBaseClass {
...
}
class CDerivedClass : public CBaseClass {
...
}

And want to implement a clone function as follows:

CBaseClass *Clone(const CBaseClass *pObject) {
}

When an object of CDerivedClass is passed to Clone, then the function will also create a CDerivedClass object and return.

When an object of CBaseClass is passed to Clone, then the function will also create a CBaseClass object and return.

How to implement such a feature?

View 3 Replies View Related

C++ :: Program For Calculating Overtime Payment Of Employee?

Jun 4, 2013

refer to this image: [URL]

program for calculating overtime payment of an employee?

View 11 Replies View Related

C++ :: Employee Database - Bizarre Error With If Statement

Dec 21, 2014

I have written a program that stores employees in a database object. You can Add, hire, fire, promote, demote, and display employees. The program uses an interface, a database class, and an employee class with member functions.

The strange behavior is in my switch statement in interface.cpp. I have a '#' that represents a command line. Add and Display functions are ok, but if I hire, fire, promote or demote. It will display '##' for the next input. I ran the debugger and after hire/fire/promote/demote is called, the first if-statement goes to 'else' and I'm trying to figure out why.

Note: main() calls mainMenu() to run the program

// interface.cpp
#include <iostream>
#include "database.h"
#include "display.h"
void mainMenu() {
displayMenu();
Database* employeeDatabase = new Database();

[Code] .....

Here are the two classes...

// database.cpp
#include <iostream>
#include <vector>
#include <memory>
#include "employee.h"
#include "database.h"
using namespace std;

[Code] .....

View 6 Replies View Related

C/C++ :: Writing Program That Will Calculate Employee Salary?

Jan 31, 2014

I am having some trouble with my class assignment. We need to write a C program that will calculate the employee salary. There are 5 employees that will need to be calculated. We are required to use a loop also.

So far this is what I have but I am receiving errors when running the program.

#include <stdio.h>
int main() {
int clock_num; /* employee clock number */
float gross; /* gross pay for week (wage * hours) */
float hours; /* number of hours worked per week */
float wage; /* hourly wage */
/* Prompt for input values from the screen */
printf ("This is a program to calculate gross pay.

[code]....

View 3 Replies View Related

C/C++ :: Employee Payroll Calculations Program For A Class

Sep 30, 2013

getting output from my code when I compile, the codeblocks ide doesnt show any errors it just doesn't give me any out put when I compile?

Here is my code:

#include <iostream>
#include <string>
#include <iomanip>  
using namespace std;  
//
//CLASS DECLARATION SECTION

[code].....

View 1 Replies View Related

Visual C++ :: How To Search For Object That Has Been Hashed

May 27, 2013

Ran into a logic issue with my hashing program that stores a state object. It's storing the object just fine now but I need to be able to search for it. The user enters a state name and I'm supposed to be able to search for it. I am at a complete loss on how to handle hashing objects.

here is the main

Code:
#include <iostream>
#include <fstream>
#include <string>
#include "hashT.h"

[Code]....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved