Thread: request for member 'KeyVal' in '((ComplexType*)this)-> As? Is that what this is?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2015
    Posts
    119

    request for member 'KeyVal' in '((ComplexType*)this)-> As? Is that what this is?

    How? Here is how it?
    Good day to all of you!
    I'm sorry, but I'm ashamed, but I can't figure out where the mistake is.
    The saddest thing is that I Google more than an hour trying to study the code carefully, and I haven't found a catch.
    I don't get it.
    I'm not going to handle the underwater stones in the code.

    D:\Classes\Com1vc\Com.cpp|20|error: request for member 'KeyVal' in '((ComplexType*)this)->ComplexType::real', which is of non-class type 'double'|

    What is this? I didn't expect that. (ComplexType *)-ComplexType: Real is it from where?

    What should I add to my code to fix it well? Where was I wrong?

    Friendly and respectful waiting for a response, please!




    Code:
    #include<iostream>
    using std::cout;
    using std::endl;
    
    template <class t>
    //neq (t t1,t t2);
    int neq (t,t); /*Ÿ€о‚о‚ип ˆаблонƒ „ƒнк†–—.*/
    
    
    class ComplexType
    {
      public:
         double real;
         double imag;
      private:
         ComplexType(double r=0.0, double i=0.0) { real=r; imag=i;}
         /*žпе€а†–йна „ƒнк†–я! =. ‘ез не— неможлива побƒдова ˆаблонно— „ƒнк†–— neq () для комплексни… ‡исел.*/
         int operator != (ComplexType & KeyVal)
         {
             if (real==real.KeyVal&&imag==imag.KeyVal) return 0;
             else                                      return 1;
         }
    };
    
    
    int main ()
    {
     // ’изна‡ен– ‚а п€о–н–†–ал–зован– зм–нн– ‚€Œо… ‚ип–в.
     int i = 1, j = 2;
     float k = 1.0, l = 2.0;
     ComplexType CTw1(1.0,1.0), CTw2(2.0,2.0);
     //На основ– ви€аз–в викликƒ ‚€ансля‚о€ бƒдƒ” ‚€и ˆаблонни… „ƒнк†–—.
     cout << "neq() for int:" << neq(i,j) << endl;
     cout << "neq() for float:" << neq(k,l) << endl;
     cout << "neq() for ComplexType:" << neq(CTw2,CTw3) << endl;
    return 0;
    }
    /*’изна‡ення ˆаблонƒ „ƒнк†–—.*/
    template <class t>
    int neq (t t1,t t2);
    {
      return  t1 != t2 ? 1 : 0;
     // return  t1 != t2; /* На сп€авд– можно й ‚ак… */
    }
    Last edited by Dmy; 08-29-2017 at 08:53 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Request For Member 'Charname'
    By Shokwav in forum C++ Programming
    Replies: 2
    Last Post: 05-19-2011, 07:46 PM
  2. Replies: 2
    Last Post: 02-04-2011, 10:07 AM
  3. Replies: 3
    Last Post: 10-16-2010, 06:27 AM
  4. Replies: 1
    Last Post: 05-18-2010, 04:14 AM
  5. Replies: 2
    Last Post: 03-17-2008, 12:21 AM

Tags for this Thread