取消引用指向结构的指针会在函数内部和外部提供不同的值

时间:2018-01-20 03:48:54

标签: c++ struct arduino

当我尝试在函数调用中访问我的waypoint struct的成员时,我得到了不同的看似垃圾错误。我把指针搞砸了吗?

的main.c

#include "navagator.h"

int main() {
     Waypoint w = {43.36, -75.1};
       w.lat = 43.36;
       w.lon = -75.1;

       Serial.print("\nWaypoint ");
       Serial.print((*&w).lat);

       nav = new Navagator(&w, 1);
}

navigator.cpp

#include navigator.h

Navagator::Navagator(Waypoint* w, int count) {
    Serial.print("Current Loc:  ");
    Serial.print(w->lat);
    Serial.print(", ");
    Serial.println(w->lon);
}

0 个答案:

没有答案