473,473 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

error: insufficient contextual information to determine type

I have created a class that contains an instance of a second class.
When i try to call a member function of the instance of the second class
from a member function of the containing class, I get the following
error message:

Insufficient contextual information to determine type.

I have generated the simplest sample I could come up with that
duplicates this error, and it is attached below. I am fairly new to
programming and hope that I am not wasting anyone's time with this, but
I have been searching the net and my reference texts for the past three
hours trying to figure it out and am completely frustrated. It must
have something to do with the second class being user defined, because
if I substitute a string object I have no problem manipulating it.
Please help!

Sample code:

#include <iostream>

using std::cout;

class FirstClass {

public:
FirstClass();
void setFirstClassValue( int );

private:
int firstClassValue;
};

FirstClass::FirstClass()
{
firstClassValue = 7;
}

void FirstClass::setFirstClassValue( int newValue )
{
firstClassValue = newValue;
}

class SecondClass {

public:
SecondClass();

private:
FirstClass instanceOfFirstClass();
};

SecondClass::SecondClass()
{
instanceOfFirstClass.setFirstClassValue( 10 ); //The problem line

};
main()
{
SecondClass instanceOfSecondClass();

Return 0;
}
Jul 23 '05 #1
2 16130
Squid Seven wrote:

private:
FirstClass instanceOfFirstClass();


This doesn't do what you think it does. This declares a private member
function called instanceOfFirstClass that takes no arguments and returns
(by value) a FirstClass object. I think what you probably want here is:
private:
FirstClass instanceOfFirstClass;
Jul 23 '05 #2
Thankyou very much - that did resolve the problem.

Phil Staite wrote:
Squid Seven wrote:

private:
FirstClass instanceOfFirstClass();

This doesn't do what you think it does. This declares a private member
function called instanceOfFirstClass that takes no arguments and returns
(by value) a FirstClass object. I think what you probably want here is:
private:
FirstClass instanceOfFirstClass;

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
19
by: Christopher | last post by:
I am getting a parse error from g++ pointing at my catch line and can't figure out whats wrong with this code: #include "BigPosInt.h" #include <iostream> #include <new> #include <assert.h> ...
3
by: Robert Neville | last post by:
I am looking for JavaScript examples on expanding contextual definition. For example, you have a word like POP3 and the user click on the word expanding it with the following contextual definition....
5
by: hpy_awad | last post by:
I wrote that example from a book and there is en error in the display module that it does not showing all the records are entered in the input module. I traced with some printf statments without...
4
by: Sagaert Johan | last post by:
i get this error if i write this : using System.Net.Sockets; .... .... TcpClient tcp; tcp=new TcpClient();
2
by: Chris Fink | last post by:
I am using the System.IO.File class to determine if a file exists on a network share. The File.Exists method keeps returning false, even though the file does exist. The MSDN documentation...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
12
by: Wilson | last post by:
Hi, while writing a simplified version of a program i created the following class, however when i went to compile and run the program there was an error saying "multiple types in one...
2
by: Vinay Sajip | last post by:
Some users of the logging package have raised an issue regarding the difficulty of passing additional contextual information when logging. For example, the developer of a networked application may...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.