Hi all,
I have this following error
In test.h
=============== =============== =============
#include <iostream>
#include <cstddef>
#include <utility>
template<typena me Tclass myclass;
template<typena me Tstd::ostream& operator<< (std::ostream&, const
myclass<T>&);
template <typename Tclass myclass {
public:
friend std::ostream& operator<< <T(std::ostream & os, const
myclass<T>& var1);
....
...
...
private:
struct mysubclass
{
int par1;
int par2;
};
};
#include "myclass.te m"
=============== =============== ===============
In myclass.tem,I have
=============== =============== =============== ==
#include <cassert>
#include <algorithm>
template<typena me T>
std::ostream& operator<< (std::ostream& values, const myclass<T>&
var1)
{
typename myclass<T>::mys ubclass *current;
current->par1=89;
............... ............... ...
............... ............... ......
}
When I compile I get the error
In myclass.tem
error: ‘par1’ was not declared in this scope
What am I doing wrong.How can solve this.
Cheers,
Sam 5 1588
On Oct 9, 2:09*pm, sam.bark...@gma il.com wrote:
Hi all,
I have this following error
In test.h
=============== =============== =============
#include <iostream>
#include <cstddef>
#include <utility>
template<typena me Tclass myclass;
template<typena me Tstd::ostream& operator<< (std::ostream&, const
myclass<T>&);
template <typename Tclass myclass {
public:
*friend std::ostream& operator<< <T(std::ostream & os, const
myclass<T>& var1);
...
..
..
private:
struct mysubclass
{
*int par1;
int par2;};
};
#include "myclass.te m"
=============== =============== ===============
In myclass.tem,I have
=============== =============== =============== ==
#include <cassert>
#include <algorithm>
template<typena me T>
std::ostream& operator<< (std::ostream& values, const myclass<T>&
var1)
{
* * * * * typename myclass<T>::mys ubclass *current;
* * * * * current->par1=89;
* * * * * ............... ............... ...
* * * * * ............... ............... ......
}
When I compile I get the error
In myclass.tem
error: ‘par1’ was not declared in this scope
What am I doing wrong.How can solve this.
Well, I don't see any error with this code,
except a runtime error, you didn't initialize the pointer "current".
and VC2005, GCC4.3, Comeau Online compiles file.
--
Best Regards
Barry
On Oct 9, 8:09 am, sam.bark...@gma il.com wrote:
I have this following error
In test.h
=============== =============== =============
#include <iostream>
#include <cstddef>
#include <utility>
template<typena me Tclass myclass;
template<typena me Tstd::ostream& operator<< (std::ostream&, const
myclass<T>&);
template <typename Tclass myclass {
public:
friend std::ostream& operator<< <T(std::ostream & os, const
myclass<T>& var1);
...
..
..
private:
struct mysubclass
{
int par1;
int par2;
};
};
#include "myclass.te m"
=============== =============== ===============
In myclass.tem,I have
=============== =============== =============== ==
#include <cassert>
#include <algorithm>
template<typena me T>
std::ostream& operator<< (std::ostream& values, const myclass<T>&
var1)
{
typename myclass<T>::mys ubclass *current;
current->par1=89;
............... ............... ...
............... ............... ......
}
When I compile I get the error
In myclass.tem
error: ?par1? was not declared in this scope
What am I doing wrong.How can solve this.
What complier are you using? What is the exact error message?
And the exact code which triggers it?
Deleting the "..." lines in your code and adding a return to the
operator<<, it compiles with all of the compilers available to
me (Sun CC, g++ and VC++), including if add code to instantiate
the function.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Thanks for the help guys.
Yeah.The pointer is to be initialised.
The exact error message is
myclass.tem: In function ‘std::ostream& operator<<(std: :ostream&,
const myclass<T>&)’:
myclass.tem:61: error: ‘par1’ was not declared in this scope
myclass.tem:64: error: ‘par2’ was not declared in this scope
cc1plus: warnings being treated as errors
I am trying to compile it in g++.
I am stumped.
On Oct 9, 2:08 pm, sam.bark...@gma il.com wrote:
The exact error message is
myclass.tem: In function ?std::ostream& operator<<(std: :ostream&,
const myclass<T>&)?:
myclass.tem:61: error: ?par1? was not declared in this scope
myclass.tem:64: error: ?par2? was not declared in this scope
cc1plus: warnings being treated as errors
I am trying to compile it in g++.
With what code? The code you posted cannot compile, as such,
because of the .... lines. Deleting those, it *does* compile
with g++ (both versions 4.1.0 and 3.4.0). So please post an
exact example (copy/pasted) of the code which doesn't compile,
with the exact error message you get, and which version of the
compiler you are using.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Thanks for you support James.Yes, you were correct.The problem was
with the way I was calling the classes.
Cheers,
Sam
On Oct 10, 7:14 pm, James Kanze <james.ka...@gm ail.comwrote:
On Oct 9, 2:08 pm, sam.bark...@gma il.com wrote:
The exact error message is
myclass.tem: In function ?std::ostream& operator<<(std: :ostream&,
const myclass<T>&)?:
myclass.tem:61: error: ?par1? was not declared in this scope
myclass.tem:64: error: ?par2? was not declared in this scope
cc1plus: warnings being treated as errors
I am trying to compile it in g++.
With what code? The code you posted cannot compile, as such,
because of the .... lines. Deleting those, it *does* compile
with g++ (both versions 4.1.0 and 3.4.0). So please post an
exact example (copy/pasted) of the code which doesn't compile,
with the exact error message you get, and which version of the
compiler you are using.
--
James Kanze (GABI Software) email:james.ka. ..@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: frankg |
last post by:
When I compile this file
------------------------------------------------------
#include <stdarg.h>
template <class Any>
void var_arg_func(int dimension_count, ...)
{
int dimensions;
va_list ap;
|
by: tirath |
last post by:
Hi all,
I have a templated class that derives from a non-templated abstract class.
How do I then cast a base class pointer to a <templated> derived class
pointer in a generalised fashion?
Here's what I'm generally trying to achieve:
I'm building (trying to anyway) a serialization library. Here's my design:
|
by: Lionel B |
last post by:
Greetings,
The following code:
<code>
template<typename T>
class A
{
protected:
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
Hello,
I have a very simple problem but cannot seem to figure it out. I have a
very simple php script that sends a test email to myself. When I debug
it in PHP designer, it works with no problems, I get the test email. If
|
by: Trevor Morgan |
last post by:
I've been having problems when a templated member function has the same name
as ANY previously defined template parameter.
Here's the simplest case that demonstrates the problem.
This fails to compile under VC++ version 7.0
It has no problems under gcc.
| |
by: Chris Dams |
last post by:
Dear all,
I found out that the program
#include<vector>
using namespace std;
int main()
{ vector<int*> v(2,0);
|
by: Robert.Holic |
last post by:
Hi All (first time caller, long time listener),
I've stumbled across a problem that I have yet to figure out,
although Im sure I'll kick myself when I figure it out. Here it is:
I need to create a templated class that accepts any type. Easy
enough I though, like this:
template<typename Type>
|
by: mattjgalloway |
last post by:
I'm having some problems with a templated member function of a templated class. Unfortunately I can't replicate it with a simple example so I know something odd must be going on!!!
Basically it's like this...
I have a few classes all templated by one type. Inside one of the classes is a templated member function. When I try to use this templated function in another class, the compiler complains with:
error: expected primary-expression...
|
by: card |
last post by:
Hi everyone,
I have a question about referencing a nested class contained within a templated class. Of course the best way to show you is by example. Here's my templated classes:
#include <stack>
template <class T>
class A
{
public:
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |