我有两个矩阵作为全局变量.但是,当我运行我的项目时,我在xCode中得到一个apache Mach-O链接器错误,该错误表明我的全局变量被多次声明.我已确定问题是我的全局变量的放置和头文件的导入.
我的svd.h在这里:
#ifndef __netflix_project__svd__
#define __netflix_project__svd__
#include <stdio.h>
#include "dataManager.h"
const float GLOBAL_AVG_SET1 = 3.608609;
const float GLOBAL_AVG_SET2 = 3.608859;
const int TOTAL_USERS = 458293;
const int TOTAL_MOVIES = 17770;
double **user_feature_table = new double *[TOTAL_USERS];
double **movie_feature_table = new double *[TOTAL_MOVIES];
void initialize(int num_features);
void train();
double predictRating(int user, int movie);
#endif /* defined(__netflix_project__svd__) */
Run Code Online (Sandbox Code Playgroud)
我的svd.cpp在这里:
#include "svd.h"
void initialize(int num_features) {
for(int i = 0; i < TOTAL_USERS; i++) {
user_feature_table[i] = new double[num_features];
for(int k = …Run Code Online (Sandbox Code Playgroud)