VS2022 继承和派生error C2228: “.Print”的左边必须有类/结构/联合

VS2022 继承和派生error C2228: “.Print”的左边必须有类/结构/联合

Rectangle M(Line k, Line g);
           
           
                 M.Print();
        ;   system("pause");
#pragma once
#include "line.h"

class Rectangle : public Line
{
public:
     Rectangle (Line k, Line g);
     double Setweight(); //设置矩形的宽
     double Sethigh();//设置矩形的长
     double setarea();//设置面积
     void Print();
    
    class Line k,g;
    


};




#pragma once
#include "stdafx.h"
#include "Rectangle.h"
#include "math.h"
#include "line.h"
#include <iostream>

using namespace std;




Rectangle::Rectangle(Line L1, Line L2):Line(k,g)

{
    k = L1;
    g = L2;
}

double Rectangle::Setweight()
{
    double w;
    w = k.getLength();
    return w;
}

double  Rectangle::Sethigh()
{
    double w;
    w = g.getLength();
    return w;;
}


double  Rectangle::setarea()
{
    double a;
    a= Sethigh() * Setweight();
    return a;
}







void Rectangle::Print()
{
    double a, b, c;
    a = Sethigh() * Sethigh();
    b = Setweight() * Setweight();
    c = sqrt(a + b);
    
  
    cout << "矩阵的宽为";
  cout << Setweight() << endl; 
    cout << "矩阵的长为";
  
    cout << Sethigh() << endl;
    cout << "矩阵的面积为";
    cout << setarea() << endl;
    cout << "矩形的对角线长为";
        cout <<c<<endl;

}


```用代码块功能插入代码,请勿粘贴截图 

   报错:.Print的左边必须有类/结构/联合

###### 我的解答思路和尝试过的方法 

怎么改才能解决啊