I use my own matrix and vector classes. I wrote them before such
things were generally available and I've stuck with them ever since.
I've just added an Octonion class derived from the vectors class and
I'm trying to do some matrix arithmetic where the elements of the
matrices are Octonions. (My Octonions are essentially 8-component
vectors with a multiplication table that I compute at runtime. Like
vectors, they are a template class, but I've yet to assign anything
but double as the template scalar)
Things have been working pretty well, but now
I've gotten this warning when trying to multiply a matrix by an
Octonion:
matrixd.cc:244: warning: passing `const Octonion<double >' as `this'
argument of
`Octonion<scala rOctonion<scala r>::operator*(c onst
Octonion<scalar >&) [with
scalar = double]' discards qualifiers
I seem to get valid results if I ignore the warning, but I'd like to
understand what it means and to modify my classes so that it no longer
occurs.
Can someone help, please?
thanks, --thelma 2 2243
On 2007-12-27 21:14, Thelma Lubkin wrote:
I use my own matrix and vector classes. I wrote them before such
things were generally available and I've stuck with them ever since.
I've just added an Octonion class derived from the vectors class and
I'm trying to do some matrix arithmetic where the elements of the
matrices are Octonions. (My Octonions are essentially 8-component
vectors with a multiplication table that I compute at runtime. Like
vectors, they are a template class, but I've yet to assign anything
but double as the template scalar)
Things have been working pretty well, but now
I've gotten this warning when trying to multiply a matrix by an
Octonion:
matrixd.cc:244: warning: passing `const Octonion<double >' as `this'
argument of
`Octonion<scala rOctonion<scala r>::operator*(c onst
Octonion<scalar >&) [with
scalar = double]' discards qualifiers
I seem to get valid results if I ignore the warning, but I'd like to
understand what it means and to modify my classes so that it no longer
occurs.
I am not quite sure (so I ought to not say anything) but have you
declared the * operator as const? E.g.:
template<class scalar>
class Octonion : public Vector
{
// ...
Octonion<scalar operator*(const Octonion<scalar >&) const;
// ...
};
Your code would probably not compiler if you had not, but who knows.
--
Erik Wikström
On Dec 27, 12:14 pm, Thelma Lubkin <the...@alpha2. csd.uwm.eduwrot e:
I use my own matrix and vector classes. I wrote them before such
things were generally available and I've stuck with them ever since.
I've just added an Octonion class derived from the vectors class and
I'm trying to do some matrix arithmetic where the elements of the
matrices are Octonions. (My Octonions are essentially 8-component
vectors with a multiplication table that I compute at runtime. Like
vectors, they are a template class, but I've yet to assign anything
but double as the template scalar)
Things have been working pretty well, but now
I've gotten this warning when trying to multiply a matrix by an
Octonion:
matrixd.cc:244: warning: passing `const Octonion<double >' as `this'
argument of
`Octonion<scala rOctonion<scala r>::operator*(c onst
Octonion<scalar >&) [with
scalar = double]' discards qualifiers
I seem to get valid results if I ignore the warning, but I'd like to
understand what it means and to modify my classes so that it no longer
occurs.
Can someone help, please?
thanks, --thelma
Could you please write what's on matrixd.cc:244 that's causing this
warning. Since error and warning messages are compiler and setting
dependent it's hard to make out the cause from these messages.
But by the look of it, it seems that your LHS operand is a const
object and your operator*() is not a const member.
Thanks and regards
Sonison James This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jim West |
last post by:
Could someone please explain to me why the code segment
class FOO {
public:
double *begin();
};
void bar(const FOO &foo) {
foo.begin();
}
|
by: Jason |
last post by:
I have a function (Inet_ntop) that returns const char * and if I try to
assign that return value to a char * variable, I get the gcc error message:
warning: assignment discards qualifiers from pointer target type
Does anyone know what this warning means? Why do I get it? The program
compiles and appears to work, but I'd like to understand...
|
by: Charlie Zender |
last post by:
Hi,
I am unable to compile a large body of code with extremely pedantic
compile time checks activate, so that warnings cause errors.
With GCC 3.3.1, I do this with
gcc -std=c99 -pedantic -Wall -Wunused -Werror -W -Wmissing-prototypes
-Wconversion -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align
-Wwrite-strings -c -o foo.o foo.c
|
by: dingoatemydonut |
last post by:
The C99 standard states:
"In the abstract machine, all expressions are evaluated as specified
by the semantics. An actual implementation need not evaluate part
of an expression if it can deduce that its value is not used and
that no needed side effects are produced (including any caused by
calling a function or accessing a volatile object)."...
|
by: Martin Jørgensen |
last post by:
Hi,
In continuation of the thread I made "perhaps a stack problem? Long
calculations - strange error?", I think I now got a "stable" error,
meaning that the error always seem to come here now (tried: visual
studio 2005 + linux/macintosh gcc)...
That's a pretty good thing. I think the error still appears using both
gcc and visual studio...
| |
by: Pietro Cerutti |
last post by:
i Group,
to my understanding, defining a function parameter as "const" means that
the function is not going to change it.
Why does the compiler says "return discards qualifiers from pointer
target type" when I *access* a member of an argument defined as const?
Please see the code below:
|
by: lovecreatesbea... |
last post by:
I'm getting `warning: return discards qualifiers from pointer target
type' at line 11 on this code from gcc.
Some people suggested in old posts that this kind of warning can be
suppressed by qualifying the return type with const. In this code it
also can be removed by removing const from the first pointer parameter
str. Are there better...
|
by: Anarki |
last post by:
The following is the program i am trying to compile
//restrict.c
#include <stdio.h>
int main()
{
char arr = "Qualifiers"
char * restrict p = arr;
int i = 0;
for(; i < 10; ++i)
|
by: DelphiCoder |
last post by:
I have the following function declared:
void RegisterMyClass(HINSTANCE hinst,
WNDPROC wproc, char* clsName)
My window procedure is defined as follows:
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam)
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |